我是 Python 的新手。我试图玩时间和日期对象。我编写了一个简单的测试程序来将字符串解析为特定的时间格式。但它抛出一个ValueError
. 你能帮帮我吗?
这是代码:
import time
testDate = "Tuesday, Febuary 23 2011 12:00:00 UTC"
today = time.strptime(testDate,"%A, %B %d %Y %H:%M:%S %Z")
print today
和错误:
Traceback (most recent call last):
File "D:\Python\PythonTest\src\helloWorld.py", line 3, in <module>
today = time.strptime(testDate,"%A, %B %d %Y %H:%M:%S %Z")
File "C:\Python27\Lib\_strptime.py", line 467, in _strptime_time
return _strptime(data_string, format)[0]
File "C:\Python27\Lib\_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data 'Tuesday, Febuary 23 2011 12:00:00 UTC' does not match format '%A, %B %d %Y %H:%M:%S %Z'