상위 폴더 import 하기

yoonene·2022년 7월 15일
import os, sys
  • sys.path에 상위 디렉토리 추가
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
  • sys.path에 2개 상위 디렉토리 추가
os.path.dirname(os.path.abspath(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))))
  • sys.path에 특정 디렉토리 추가
sys.path.append("디렉토리 경로")
profile
NLP Researcher / Information Retrieval / Search

0개의 댓글