Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 datetime strftime()方法需要年份>;=1900_Python 2.7_Cx Oracle - Fatal编程技术网

Python 2.7 datetime strftime()方法需要年份>;=1900

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

我的数据集第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"

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()
可能重复的