在 Python 更正中读取和写入 CSV 文件



我需要一些帮助来确定如何在将信息写入 csv 文件后输出我的代码,请您帮助完成 if get_bool_input) 位下方的位。

文件名 = class_name + ".csv"

with open('filename.csv', 'a',newline='') as fp:
    a = csv.writer(fp, delimiter=',')
    data=[['Name','Score'],
          [name,score]]
    a.writerows()

if get_bool_input("Do you wish to view previous results for your class"):
    print filename
else:
    input ("Press any key to exit")

a.writerows更改为a.writerows()

这应该可以解决它。如果没有,请提供您的回溯。

最新更新