반응형
import os
current_path = os.path.dirname(__file__) #현재 파일의 위치 반환
image_path = os.path.join(current_path, "images") #image 폴더 위치 반환
background = pygame.image.load(os.path.join(image_path, "background.png"))
절대경로를 일일이 입력해주지 않고
os를 이용해서
원하는 파일의 경로를 구하고
os.path.join(경로, 파일명) 을 이용해서
경로를 구해줄 수 있다.
반응형
'Python' 카테고리의 다른 글
vscode selenium python webdriver 바로 꺼짐 오류 (5) | 2022.01.05 |
---|---|
pyinstaller: command not found , pyinstaller 에러 (0) | 2021.12.27 |
Python for-else (0) | 2021.12.23 |