import csv
with open('v.csv', 'w') as csvfile:
cwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
for w, c in p.items():
cwriter.writerow(w + c)
这里,p
是一个字典,w
并且c
都是字符串。
当我尝试写入文件时,它会报告错误:
ValueError: I/O operation on closed file.