【发布时间】:2013-08-01 08:02:42
【问题描述】:
我的C:\Python27\word_data 中有一个包含两个.py 文件的目录,分别称为main.py 和gethtml.py。
我想在我的main.py 中导入gethtml.py,从该文件中打印def,我尝试这样做:
import gethtml
print gethtml.getHtmlText()
当我在 Python shell 中运行它时,我得到一个错误:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
execfile("word_rank/main.py")
File "word_rank/main.py", line 3, in <module>
import gethtml
ImportError: No module named gethtml
我错过了什么?
【问题讨论】:
-
如果您从
word_rank目录运行它,它将起作用。