1. 程式人生 > >python在引用其他資料夾下自定義函式

python在引用其他資料夾下自定義函式

專案層次結構類似於此,現在需要在stup.py檔案中引用A.py檔案中定義的函式 test,

可以採用:

from Lib.A import test

A.py內容:

#-*- coding: UTF-8 -*-


import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import os

def test():
    print "hello python!"
stup.py內容:

#-*- coding: UTF-8 -*-


import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import os
from Lib.A import test

test