导入模块,这是一个Python新手问题:嵌套包
我有以下目录结构:
test
-- test_file.py
a
-- b
-- module.py
其中test
,a
和b
是文件夹。 test
和a
都处于同一水平。
module.py有一个名为shape
的类,我想在test_file.py中实例化它的一个实例。我该怎么做?
我曾尝试:
from a.b import module
但我得到:
ImportError: No module named a.b
请参阅http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python。 – 2010-02-02 10:30:33