4
在Snow Leopard上运行python,我无法导入'时间'模块。在ipython中工作。没有任何正在加载的.pythonrc文件。使用相同解释器的“输入时间”的脚本运行良好。不知道如何解决这个问题。任何人有想法?不能在python中导入时间,得到'AttributeError:struct_time'如何解决?
[[email protected] ~]$ python2.6
Python 2.6.6 (r266:84292, Sep 1 2010, 14:27:13)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "time.py", line 4, in <module>
t = now.strftime("%d-%m-%Y-%H-%M")
AttributeError: struct_time
>>>
[[email protected] ~]$ ipython-2.6
Python 2.6.6 (r266:84292, Sep 1 2010, 14:27:13)
Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: import time
In [2]:
就是这样,感谢您的快速反应。我有一个随机脚本,我在几天前测试了我当前的工作目录中的time.py。移动它解决了这个问题。 – wiggles 2010-10-22 22:00:39