简体   繁体   中英

Importing a python module from another directory

The below is what my folder for my project looks like. The code itself relies on the files that are contained within the Project folder - so my question is simple.

What is the simplest way to use import Maths from a differant directory? I have gotten it to work before, but it never loads the files as well.

Project (Main Folder):

resources
    bg.png
    student.png
    stylesheet.css
    template.html

configFile.pickle
Maths.pyw
userKeycodes.pickle

add project folder to sys.path

import sys
sys.path.append('/project/folder')
import Maths

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM