这是一个创建于 4207 天前的主题,其中的信息可能已经有所发展或是发生改变。
1. 今天无意中写了个python脚本,其中有导入time包,但报错,之前一直都没有问题的,并且在bash下也没有问题
>>python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 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 10, in <module>
print time.time()
TypeError: 'module' object is not callable
之后我又重新source $HOME/.profile,还是不行,不知原因出在哪里,bash下到没问题
2.还有一个问题,现在想不起来了......
5 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
wwwjfy 2012-09-20 11:24:52 +08:00 1
基本看来是你的python脚本就是time.py,import的是当前目录下的time,不是系统的time,然后time.py里又import了系统的time,所以time.time就是系统的time,要不你试试time.time.time()
|
|
|
3
gavingeng 2012-09-20 11:30:11 +08:00
@ wwwjfy 为何在bash下就没什么问题,反而在zsh下出现这个问题呢
|
|
|
4
wwwjfy 2012-09-20 12:08:56 +08:00
@ gavingeng 跟zsh应该没关系,最多也就是类似自动补全或切换路径之类的,要么是执行所在的路径不一样..
|
|
|
5
bitsmix 2012-09-20 12:10:53 +08:00
#python新手必犯错误#
|