我目前在麻烦一种方法来将结果保存到通过sys.argv [1]提供的文件中。我向python脚本提供了csv。
我的csv具有这样的格式的数据
3/4/20
3/5/20
3/6/20
Run Code Online (Sandbox Code Playgroud)
我尝试使用append(),但收到错误,也尝试使用write()
import sys
file = open(str(sys.argv[1])) #enter csv path name, make sure the file only contains the dates
for i in file:
addedstring = (i.rstrip() +',09,00, 17')
finalstring = addedstring.replace("20,", "2020,")
file.append(i)
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏!