上代码:
import csv
csvFile = open("C:/Users/Administrator/Desktop/1.csv", 'w', newline='', encoding='utf-8')
writer = csv.writer(csvFile)
csvRow = []
f = open("C:/Users/Administrator/Desktop/np.txt", 'r', encoding='GB2312')
for line in f:
csvRow = line.split()
writer.writerow(csvRow)
f.close()
csvFile.close()
实现效果如下:
标签:--------,csv,encoding,writer,csvRow,txt From: https://www.cnblogs.com/cherishthepresent/p/17617945.html