python将txt文件改为csv import csv with open('file1.csv','w') as f: f_csv=csv.writer(f) for line in open('1.txt', 'r'): line_sp = line.strip().split() #strip()去除首尾中括号内指定的字符,split()按照括号内的内容进行分割 f_csv.writerow(line_sp) 运行结果: