Py3k identical code executing differently in dynamic shell and from file [closed]
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this questionThe code I'm using is:
import time
print(time.strftime("%H:%M:%S"))
In the dynamic shell, this (as you would expect) outputs a formatted string, e.g. 03:21:35
When executing the exact same code from a file, it throws the following error:
Traceback (most recent call last):
File "main.py", line 2, in <module>
print(time.strfime("%H:%M:%S"开发者_开发百科))
AttributeError: 'module' object has no attribute 'strfime'
Anybody got any idea as to why this might be happening, and more importantly, how to fix it?
You've got a typo:
print(time.strfime("%H:%M:%S"))
should be
print(time.strftime("%H:%M:%S"))
精彩评论