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