Errno 2 : No such File or Directory 해결 방법
설정 path가 어떨때 가끔 다른 directory 로 이동되는 경우가 발생한다. (특히 생성 후 파일을 이동한 경우 자주 발생)
import os
# Get the current working directory (cwd)
currentPath = os.getcwd()
이를 통해 현재 프로그램에서 포인팅하고 있는 directory를 확인할 수 있게 된다.
그러면, 그 directory를 어떻게 바꾸냐? os.chdir("변경할 path") 를 통해 포인팅하는 directory를 바꾸면 끝.
# change path
os.chdir("변경할 path")
# change path (하위 폴더일 경우 유용)
os.chdir(currentPath+"/하위 폴더")
정상적으로 작동하게 된다.
'Python' 카테고리의 다른 글
[Python] Iterate over characters of a string in Python (0) | 2023.02.08 |
---|---|
[Python/Pandas] Index를 이용해서 데이터의 값을 찾아보기 (0) | 2022.12.23 |
[파이썬/Pandas] If Statement (0) | 2022.12.19 |