Python: Very simple strptime() call throws error
一些非常简单的代码会导致一个神秘的错误,Google没有给我任何帮助......
码:
1 2 3 4 5 6 | import sys import datetime for line in sys.stdin: date = datetime.datetime.strptime(line, '%Y%m%dT%H%M%S') print date |
stdin上的前几个输入行:
1 2 3 4 5 6 | 20101119T141500 20101119T164500 20110310T081500 20110310T113000 20100218T113000 ... |
错误:
1 2 3 4 5 6 7 8 | Traceback (most recent call last): File"time.py", line 5, in <module> date = datetime.datetime.strptime(line, '%Y%m%dT%H%M%S') File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 13, in <module> import time File"<path>", line 5, in <module> date = datetime.datetime.strptime(line, '%Y%m%dT%H%M%S') AttributeError: _strptime |
平台:Mac OS X 10.7.3,Python 2.7.1
您调用脚本"time.py",遮蔽