1. 暫時添加文件路徑到系統路徑中:
import sys
sys.path.append('/Users/abcdefg/Documents/life/miscellaneous/python_function')
2. 加載相應的python文件:
import file1
3. file1.function1就可以了
需要注意的是: file1的名字不要與python現有的包名衝突!
參考:
https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path