Import file from parent directory?

后端 未结 6 1957
悲哀的现实
悲哀的现实 2020-12-08 18:25

I have the following directory structure:

application
    tests
        main.py
    main.py

application/main.py contains some functions.

6条回答
  •  囚心锁ツ
    2020-12-08 18:35

    You cannot import things from parent/sibling directories as such. You can only import things from directories on the system path, or the current directory, or subdirectories within a package. Since you have no __init__.py files, your files do not form a package, and you can only import them by placing them on the system path.

提交回复
热议问题