프로그래밍 언어/Python 3
[Python] 파일 처리 관련 명령어
UltraLowTemp-Physics
2021. 6. 22. 14:49
1. 파일 및 디렉토리의 존재 여부를 확인할 때
import os.path
os.path.exists(fname)
- 리턴값:
1) 파일 또는 디렉토리가 존재하는 경우: True
2) 파일 또는 디렉토리가 존재하지 않을 경우: False
2. 파일의 존재 여부를 확인할 때 (디렉토리 x)
import os.path
os.path.isfile(fname)
- 러턴값:
1) True (파일이 존재할 경우)
2) False (파일이 존재하지 않을 경우)