Python import from parent directory

前端 未结 5 1225
渐次进展
渐次进展 2020-12-08 05:02

I have the following:

         ModuleFolder
              |
              |-->. ModuleFile.py .
              |
              \'-->. TestsFolder .
             


        
5条回答
  •  无人及你
    2020-12-08 05:58

    It's better to insert your relative path at the begening of sys.pathlike this:

    import sys
    sys.path.insert(0, '../')
    

提交回复
热议问题