我的輸入字符串是'16-MAR-2010 03:37:04'
,我想將它存儲爲日期時間。使用datetime.strptime時'ValueError:時間數據...與格式不匹配'
我試圖使用方法:
db_inst.HB_Create_Ship_Date = datetime.strptime(fields[7]," %d-%b-%Y %H:%M:%S ")
fields[7] = '16-MAR-2010 03:37:04'
我得到一個錯誤:
::ValueError: time data '16-MAR-2010 03:37:04' does not match format ' %d-%b-%Y %H:%M:%S '
語言環境模塊文檔中提到 「」「ABMON_1 ... ABMON_12 返回縮寫名稱的第n個月「」「但這些(和其他有用的東西)似乎並不存在。任何線索? –
@John:使用WinXP Python版本2.5的前後空格。剛剛嘗試在Ubuntu(Python 2.6.4)並得到了ValueError。 – bernie
剛剛嘗試了什麼版本的Python上* nix的表現形式? –