Ala*_*ano 1 python python-2.7 datetime-parsing
我需要解析日期和时间.这是我得到的:
import time
a = time.strptime('Apr 28 2013 23:01', "%b %d %y %H:%M")
print a
Run Code Online (Sandbox Code Playgroud)
但它给了我
Traceback (most recent call last):
File "/home/aaa/Documents/python_test.py", line 17, in <module>
a = time.strptime('Apr 28 2013 23:01', "%b %d %y %H:%M")
File "/usr/lib/python2.7/_strptime.py", line 467, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data 'Apr 28 2013 23:01' does not match format '%b %d %y %H:%M'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
Jon*_*nts 11
%y应该是%Y一个4位数年...
来自文档:
%y Year without century as a decimal number [00,99].
%Y Year with century as a decimal number.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
551 次 |
| 最近记录: |