我有一個日期時間字符串,我不知道如何在Python中解析它。在Python中分析時間字符串
的字符串是這樣的:
Tue May 08 15:14:45 +0800 2012
我試圖
datetime.strptime("Tue May 08 15:14:45 +0800 2012","%a %b %d %H:%M:%S %z %Y")
但Python會引發
'z' is a bad directive in format '%a %b %d %H:%M:%S %z %Y'
根據Python的文檔:
%z UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).
什麼是解析這個時間字符串的正確格式?
相關:Python的:解析日期與時區從一個電子郵件](http://stackoverflow.com/q/1790795/4279) – jfs