python中如何调用.py文件

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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章