我试着在3后面加上一个逗号
因此,如果输入数据如下所示:1234,1,1/1/2010,This is a test. One, two, three.
我希望python将字符串转换为:
^{pr2}$
引号总是需要加在3个逗号之后
我使用的是Python 3.1.2,到目前为止,我有以下内容:i_file=open("input.csv","r")
o_file=open("output.csv","w")
for line in i_file:
tokens=line.split(",")
count=0
new_line=""
for element in tokens:
if count = "3":
new_line = new_line + '"' + element + '"'
break
else:
new_line = new_line + element + ","
count=count+1
o_file.write(new_line + "\n")
print(line, " -> ", new_line)
i_file.close()
o_file.close()
当我尝试运行脚本时,它会立即关闭,并且不会产生任何输出
你能看出怎么了吗?在
谢谢