1. 程式人生 > >讀寫文件print函數操作

讀寫文件print函數操作

int pan style col \n spa div inf pen

with open(file1, encoding=utf-8) as inf, open(file2, w, encoding=utf-8) as outf:
    for line in inf:
        print(*[ word for word in line.split()],file=outf)
        # outf.write(line)
        # outf.write(‘ ‘.join([word for word in line.split()]))
        # outf.write(‘\n‘)

讀寫文件print函數操作