python设置环境变量
方法1:
当程序开发完毕,就可以添加到
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages'中
import sys,os sys.path ['', '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip', '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4', '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages']
就使用方法1
方法2:
import sys import os pre_path = os.path.abspath('/Users/Alan/desktop/Alanproject/day5/my_pj') #设置环境变量,把该主目录添加到sys.path里.文件退出则无效,所以写死在这个主文件 sys.path.append(pre_path) from backend.logic import view,handle view.home() view.movie() handle.cal()
我可以输,但我不会认输