小编Jer*_*Lin的帖子

如何将结果保存到文件中?

我目前在麻烦一种方法来将结果保存到通过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)

任何帮助是极大的赞赏!

python csv for-loop python-3.x

3
推荐指数
1
解决办法
37
查看次数

标签 统计

csv ×1

for-loop ×1

python ×1

python-3.x ×1