File9 Python 현재 디렉토리와 파일의 디렉토리를 찾으세요 [중복], Find the current directory and file's direc 질문How do I determine: the current directory (where I was in the shell when I ran the Python script), and where the Python file I am executing is? 답변파이썬 파일이 포함된 디렉토리의 전체 경로를 얻으려면 해당 파일에 다음을 작성하십시오:import os dir_path = os.path.dirname(os.path.realpath(__file__)) (위의 주문은 현재 작업 디렉토리를 변경하기 위해 os.chdir()를 이미 사용한 경우 작동하지 않습니다. __file__ 상수의 값은 현재 작업 디렉토리를 기준으로 상대적이며 os.chdir() 호출에 의해 변경되지 않습니다.)현재 작업 디렉.. 2023. 5. 6. 이전 1 2 3 다음