我的 python 不知怎的在同一目录中找不到任何模块。
我究竟做错了什么? (python2.7)
所以我有一个目录“2014_07_13_test”,其中有两个文件:
- test.py
- hello.py
哪里你好.py:
# !/usr/local/bin/python
# -*- coding: utf-8 -*-
def hello1():
print 'HelloWorld!'
和测试.py:
# !/usr/local/bin/python
# -*- coding: utf-8 -*-
from hello import hello1
hello1()
仍然 python 给我
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 4, in <module>
ImportError: No module named hello
怎么了?
将 test.py 中的导入更改为:
from .hello import hello1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)