0
我是python新手,现在正在学习如何导入模块或函数,但是我收到了这些发布的错误。在Python代码保存名下:hello_module.py
在Python中使用导入命令时出错
Python代码:
def hello_func():
print ("Hello, World!")
hello_func()
import hello_module
hello_module.hello_func()
错误消息:
Traceback (most recent call last):
File "C:/Python33/hello_module.py", line 9, in <module>
import hello_module
File "C:/Python33\hello_module.py", line 10, in <module>
hello_module.hello_func()
AttributeError: 'module' object has no attribute 'hello_func'
import hello_module不应该在hello_module.py中。它没有任何意义。 – njzk2 2013-05-03 17:27:48