感谢各位的回应。
因此,通过这段代码,我得到了以下输出:
import csv
def parse_calendar(infile, outfile):
with open(outfile, 'w', newline='') as output:
with open(infile, newline='') as input:
reader = csv.reader(input, delimiter=',', quotechar='"')
next(reader, None) # skip the headers
writer = csv.writer(output, delimiter=',', quotechar='"')
for row in reader: # process each row
replaced = row[0].replace('/','')
row[0] = replaced
writer.writerow(row)
01012018,元旦,美国北卡罗来纳州
01012018,新年,N,C,CA
01152018,马丁·L·金戴,北卡罗来纳州,美国
如果类型是字符串,我需要在脚本中添加什么代码才能使格式从01012018变为20180101?对于每条线,然后偏离路线。
非常感谢。谢谢。