【发布时间】:2015-11-30 07:08:11
【问题描述】:
我在使用这张表时遇到了一些问题:
import csv
with open('chill.csv','wb') as f:
writer = csv.writer(f)
for s in range(0,70,5):
for t in range(-25,10,5):
print 13.127 + 0.6215*t-11.362*s**0.16+0.396*t*s**0.16, '\t',
print
writer.writerow([13.127 + 0.6215*t-11.362*s**0.16+0.396*t*s**0.16])
问题是行和列的输入(s 和 t)被直接采用并详细说明到 print 语句中,但我需要在行和列中显示这些值的来源结果得出。此外,我尝试使用常用命令将表导出到 .csv 文件,但 Python 给了我一个运行时错误:
ValueError: I/O operation on closed file。我该如何解决这两个问题?
顺便说一句,我正在使用 Python 2.7。
【问题讨论】: