Python 2.7 datetime strftime()方法需要年份>;=1900
我的数据集第4列有1515年的日期,有没有办法绕过这个错误Python 2.7 datetime strftime()方法需要年份>;=1900,python-2.7,cx-oracle,Python 2.7,Cx Oracle,我的数据集第4列有1515年的日期,有没有办法绕过这个错误 cols[4] = cols[4] and cols[4].strftime("%d/%m/%Y") or "" ValueError: year=1515 is before 1900; the datetime strftime() methods require year >= 1900 以下是确切的代码: cursor.execute(SQL) filename = r"C:\Projects\OPEN_KCI3.csv
cols[4] = cols[4] and cols[4].strftime("%d/%m/%Y") or ""
ValueError: year=1515 is before 1900; the datetime strftime() methods require year >= 1900
以下是确切的代码:
cursor.execute(SQL)
filename = r"C:\Projects\OPEN_KCI3.csv"
with open(filename, "wb") as fout:
writer = csv.writer(fout)
#writer.writerow([i[0] for i in cursor.description ]) # heading row
for row in cursor.fetchall():
cols = list(row)
cols[3] = cols[3] and cols[3].strftime("%d/%m/%Y") or ""
cols[4] = cols[4] and cols[4].strftime("%d/%m/%Y") or ""
writer.writerow(cols)
cursor.close()
connection.close()
可能重复的