相关疑难解决方法(0)

ValueError:关闭文件的I/O操作

import csv    

with open('v.csv', 'w') as csvfile:
     cwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)

for w, c in p.iteritems():
    cwriter.writerow(w + c)
Run Code Online (Sandbox Code Playgroud)

这里,p是一本字典,w并且c都是字符串.

当我尝试在文件中写入时,它报告错误:

ValueError : I/O operation on closed file.
Run Code Online (Sandbox Code Playgroud)

帮助我,我是python的新手.我正在使用Python 2.7.3提前谢谢你.

python csv io file-io

91
推荐指数
2
解决办法
24万
查看次数

标签 统计

csv ×1

file-io ×1

io ×1

python ×1