Importing modules from parent folder

前端 未结 22 3115
梦毁少年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:45

    In a Linux system, you can create a soft link from the "life" folder to the nib.py file. Then, you can simply import it like:

    import nib
    

提交回复
热议问题