Some very simple code leads to a mystifying error, and Google gives me nothing...
Code:
import sys
import datetime
for line in sys.stdin:
date = datetime.datetime.strptime(line, '%Y%m%dT%H%M%S')
print date
First few input lines on stdin:
20101119T141500
20101119T164500
20110310T081500
20110310T113000
20100218T113000
...
Error:
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
Platform: Mac OS X 10.7.3, Python 2.7.1
You called your script "time.py", shadowing the time module. Don't do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With