os 모듈의 os.path.exists(directory)를 사용하여 디렉토리 존재 여부를 확인할 수 있습니다.
예시
import os
if not os.path.exists('my_folder'):
print("Given path doesn't exist")
else:
print("Given path exists") 실행하고 폴더가 이미 있는 경우 다음 메시지가 표시됩니다.
"Given path exists"
os 모듈의 os.path.exists(directory)를 사용하여 디렉토리 존재 여부를 확인할 수 있습니다.
import os
if not os.path.exists('my_folder'):
print("Given path doesn't exist")
else:
print("Given path exists") 실행하고 폴더가 이미 있는 경우 다음 메시지가 표시됩니다.
"Given path exists"