📜  如何使用python代码示例替换csv文件中的单词

📅  最后修改于: 2022-03-11 14:45:39.732000             🧑  作者: Mango

代码示例1
import csv

inputfile = csv.reader(open('civil-war-battles.csv','r'))
outputfile = open('placelist.txt','w')

i=0

for row in inputfile:
    place = row[2].replace(' ,',',')
    print place
    outputfile.write(place+'\n')
    i+=1