我的代码遇到了一些麻烦,如果有人可以尝试和提供帮助,我会很痛苦。问题是(在python上),是当用户输入要创建的csv文件的名称时。CSV文件仅在程序完成后显示。但是,我想在 csv 中放入一些东西,因为它还没有被创建,我不能。这是我的代码...
import csv
def start():
NewCSV = input('Name of csv: ')
with open(NewCSV + '.csv', 'w') as myfile:
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
Code_that_writes_in_CSV()
def Code_that_writes_in_CSV():
print('') #Cant write this code because the file isn't created until the programme finishes
start()
如果有人可以在程序运行时帮助更新代码,我们将不胜感激。:)
当年话下
相关分类