开发者

Py3k identical code executing differently in dynamic shell and from file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

The 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"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜