파이썬 폴더 체크

ALL

Python 파일, 폴더 체크(exists) 사용법 예제

파일 또는 폴더를 생성하는 경우 지정한 경로에 파일이나 폴더가 있는지 먼저 체크하고 싶은 경우가 있습니다.체크 방법 예제를 보도록 하겠습니다.파일 존재 체크import osos.path.exists("./test1/test1.txt")결과존재하는 경우 : Ture존재하지 않는 경우 : False폴더 존재 체크import osos.path.exists("./test1")결과존재하는 경우 : Ture존재하지 않는 경우 : False파일인지 아닌지 체크파일일 경우import osos.path.isfile("./test1/test1.txt...