Django – Import von Python-2-Layer-Ordnern
typecho
typecho 2017-07-05 10:27:14
0
1
866

Konto (Ordner)

alimns.py (这里是要导入的)

mns_python(Ordner)

mns(文件夹)
    account.py(被导入的)

So importieren Sie das

typecho
typecho

Following the voice in heart.

Antworte allen(1)
Ty80

首先我们要跳到与Account文件件同级的地方
import sys
sys.path.append('..')
调用sys模块,sys.path 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值
..跳到上一级目录
然后就可以直接from mns_python.mns import account.py
注意:mns_python里面需要有__init__.py文件(我就被坑在这里 — —,希望大家应以为戒)

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!