Importing modules from parent folder

前端 未结 22 2678
梦毁少年i
梦毁少年i 2020-11-21 23:19

I am running Python 2.5.

This is my folder tree:

ptdraft/
  nib.py
  simulations/
    life/
      life.py

(I also have __init

22条回答
  •  既然无缘
    2020-11-21 23:34

    Don't know much about python 2.
    In python 3, the parent folder can be added as follows:

    import sys 
    sys.path.append('..')
    

    ...and then one is able to import modules from it

提交回复
热议问题