2017-10-13 71 views
0

我試圖將日期時間轉換爲人性化的格式,但在轉換過程中不斷收到錯誤,我不是什麼即時錯過匹配當前格式。Python - 日期時間對話,匹配.7930000Z?

我認爲它的7930000Z多數民衆贊成在導致這個問題,一切似乎直截了當。

我用盡,%FZ和%SZ,沒有運氣迄今

>>> datetime.strftime(datetime.strptime('2017-09-18T21:20:33.7930000Z', '%Y-%m-%dT%H:%M:%S.%fZ'),'%d/%m/%y %H:%M:%S') 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
    File "/usr/local/lib/python3.6/_strptime.py", line 565, in _strptime_datetime 
    tt, fraction = _strptime(data_string, format) 
    File "/usr/local/lib/python3.6/_strptime.py", line 362, in _strptime 
    (data_string, format)) 
ValueError: time data '2017-09-18T21:20:33.7930000Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' 
+1

''%Y-%間%的dT%H:%M:%S.%f0Z'' – Goyo

+0

@Goyo是做到了! – AlexW

+0

如果最後一位數字不是0,將會失敗: -/ – Benjamin

回答