计算机@linux_python_R 技术帖

import另一个目录下的py文件

2018-01-07  本文已影响0人  SSIGMA

import文件夹A的py文件

  test
    -- A
      -- __init__.py
      -- a.py
    -- B
      -- b.py

方法 1

对b.py文件

import sys
sys.path.insert(0, '..')
from A import a

方法2

在test下创建 __init__.py

然后对b.py

from test.A import a

参考资料

上一篇 下一篇

猜你喜欢

热点阅读