代码示例:
import csv
with open('F:\\test.csv','w') as f:
f_csv=csv.writer(f)
for line in open('F:\\trainlist01.txt', 'r'):
new_line = line.strip().split()
f_csv.writerow(new_line)
txt文件:
csv文件:
参考:
https://blog.csdn.net/katyusha1/article/details/81606175
https://www.cnblogs.com/youyou0/p/8921719.html