python类的使用与多文件组织

多文件的组织

跨目录级导入模块

from ..xxfile import xxmodule    #从上级目录中的xxfile中导入xxmodule
import xxsub_dir.xxfile    #从xxsub_dir文件夹中导入所有模块 

执行时的命令

python -m pkg.tests.core_test    #去最顶级执行

(refer) [http://stackoverflow.com/questions/11536764/how-to-fix-attempted-relative-import-in-non-package-even-with-init-py/27876800#27876800]

posted @ 2017-04-23 20:22  fariver  阅读(2950)  评论(0编辑  收藏  举报