0
我想加入多個文本文件一起使用zip功能,但我不斷收到錯誤加入兩個文本文件的一面,TypeError: coercing to Unicode: need string or buffer, generator found
類型錯誤,而試圖通過側
這是我的代碼,
filepaths = ['file1.txt', 'file2.txt', 'file3.txt']
with open('op.txt', 'w') as f:
temp = zip(*[open(fpath for fpath in filepaths)])
for lines in temp:
outfile.write('\t'.join(line.strip() for line in lines) + '\n')
請幫我看看這個錯誤,我是新手使用zip編寫的腳本& python
我想你想'[開(fpath)在文件路徑fpath]' 。 –