2011-05-25 58 views
0

可能重複:
Parse date and format it using python?顯示從字符串日期在Python

我在蟒蛇以下字符串:

2011-05-25T02:11:04Z 

我怎樣才能將其轉換爲

May, 25th 2:11 
+0

您也可以使用[isodate](http://pypi.python.org/pypi/isodate/),因爲該字符串是有效的[ISO-8601](http://en.wikipedia.org/wiki/) ISO_8601)日期字符串。 – 2011-05-25 14:18:27

回答

2

datetime.datetime.strptime('2011-05-25T02:11:04Z', '%Y-%m-%dT%H:%M:%SZ')爲您提供具有正確日期/時間的datetime.datetime對象。