方法1:
当程序开发完毕,就可以添加到
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages'中
import sys,ossys.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 sysimport ospre_path = os.path.abspath('/Users/Alan/desktop/Alanproject/day5/my_pj')#设置环境变量,把该主目录添加到sys.path里.文件退出则无效,所以写死在这个主文件sys.path.append(pre_path)from backend.logic import view,handleview.home()view.movie()handle.cal()