python中如何調用.py文件
author@jason_ql(lql0716)
http://blog.csdn.net/lql0716
- 1、同一路徑下的調用
import other
other.function()
- 2、同一個路徑下調用某個函數
form other import ff
ff(x,y)
- 3、不同路徑,引用所在路徑的方法
import sys
sys.path.append('D:/')
import other
print other.f(x,y)
- 4、不同路徑,使用imp方法
import imp
other = img.load_source('other', 'D:/other.py')
import other
print other.f(x,y)