기타 분류
파이썬 여러파일 행으로 결합
작성자 정보
- ADKye 작성
- 작성일
컨텐츠 정보
- 249 조회
-
목록
본문
명령어
python combine_files.py
---------------
def combine_files(input_files, output_file):
with open(output_file, 'w', encoding='utf-8') as outfile:
for lines in zip(*(open(file, 'r', encoding='utf-8') for file in input_files)):
outfile.write('\t'.join(line.strip() for line in lines) + '\n')
if __name__ == "__main__":
input_files = ["1.txt", "2.txt", "3.txt"]
output_file = "combined.txt"
combine_files(input_files, output_file)
관련자료
댓글 0
등록된 댓글이 없습니다.