책에서 인터넷 사진 내려 받기 코드를 실행하면 permission denied 에러가 발생한다.

이럴때 아래와 같이 os 모듈로 디렉토리 변수를 설정하면 정상 저장된다



###########################################################################
## 절대 파일 경로와 Python script가 있는 디렉토리 구하기
########################################################################### import os
#
# # 절대 경로 만들기
# mypath = "C:\Pathon36"
# fullfilename = os.path.join(mypath,"text.txt")
# print(mypath)
# print(fullfilename)
#
#
# #현재 script가 있는 파일 디렉토리 경로 찾기 currentPath = os.path.dirname(os.path.abspath(__file__))
print(currentPath)

반응형

+ Recent posts