I currently have a directory structure like so:
- App
-- Model
-- Controller
-- View
-- main.py
I want to import main.py into a class into a controller file for testing purposes. How can I achieve this?
Add an empty __init__.py
file in the directory App
to turn that directory into a package .
Then, provided the /path/to/App
is visible in the sys.path
of your python environment, you should be able to:
from App import main
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.