http://docs.python.org/library/time.html#time.strptime"rel=“noreferer”>strptime(
大致如下:
>>> from datetime import datetime
>>> date_str = Tue May 08 15:14:45 +0800 2012
>>> date = datetime.strptime(date_str, %a %B %d %H:%M:%S +0800 %Y )
>>> date
datetime.datetime(2012, 5, 8, 15, 14, 45)
令人不快的是,也许其他人可以帮助他这样做。
http://docs.python.org/library/time.html#time.strftime”rel=“noreferer”>http://docs.python.org/library/time.html#time.strftime 。 印刷版也一样。
帮助的希望
标记
PS, Your best bet for timezones in installing pytz from pypi. ( http://pytz.sourceforge.net/ )
in fact I think pytz has a great datetime parsing method if i remember correctly. The standard lib is a little thin on the ground with timezone functionality.