sys.path에 저장되지 않은 디렉토리에서 스크립트를 가져 오는 데 어려움이 있습니다. "development"라는 디렉토리에 test.py라는 이름으로 저장 한 스크립트가 있고 index.py라는 현재 스크립트에서 함수를 가져올 수 있도록 sys.path에 개발 디렉토리를 추가하려고합니다. 내가 수신하고 오류 여기python의 새로운 sys.path
def printline():
print "I am working"
된다
import sys
sys.path.append ('/Users/master/Documents/Development/')
import test
printline()
printline()로 test.py에 정의되어 있습니다 : 여기
는 index.py 내 코드입니다 :
Traceback (most recent call last):
File "/Users/master/Documents/index.py", line 6, in <module>
printline()
NameError: name 'printline' is not defined
어떻게 작동시킬 수 있습니까?
감사합니다.