■ isdir 함수를 사용해 디렉토리 경로 여부를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 |
import os.path print(os.path.isdir("C:\\Program Files\\Python310")) print(os.path.isdir("C:\\Program Files\\Python310\\python.exe")) """ True False """ |
※ 해당 경로가 존재하지 않은 경우 False를 반환한다.