0
Python 3.4 ...我試圖將CSV中的特定列從字符串轉換爲datetime並將其寫入文件。我能夠讀取並轉換它,但需要幫助將日期格式更改寫入文件(最後一行代碼 - 需要修改)。對於最後一行代碼,我得到以下錯誤錯誤:預期的順序。將CSV字段的格式從字符串轉換爲日期時間
import csv
import datetime
with open ('/path/test.date.conversion.csv') as csvfile:
readablefile = csv.reader(csvfile)
writablefile = csv.writer(csvfile)
for row in readablefile:
date_format = datetime.datetime.strptime(row[13], '%m/%d/%Y')
writablefile.writerow(date_format)