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)