꼭 파일 이름을 변수에 넣어줘야 함.
예시 :
file = 'test.json'
if os.path.isfile(file):
print("Yes. it is a file")
if os.path.isfile('test.json'):
print("Yes. it is a file")
=> 파일 이름 직접 넣어주면 오류남
https://wikidocs.net/14304
0.파일 존재여부 확인하는 방법
파일 입출력 기능을 사용함에 있어서 파일/디렉토리의 존재 유무를 확인하다. 경로 및 파일 이름 관련 함수들의 기능은 다음과 같다. | 함수 | 기능 | | ------ ...
wikidocs.net
'기록 > Python' 카테고리의 다른 글
[Python] 파이썬 to_csv 한글 깨짐 해결 방법 (0) | 2022.06.28 |
---|---|
[Python] 파이썬 init 이란 (0) | 2022.06.21 |
[Python] 파이썬 'is None'과 '==None' 차이점 (0) | 2022.06.21 |
[Python] TypeError: unsupported operand type(s) (0) | 2022.06.21 |
[PyCharm] 파이참 라이브러리 연결 오류 (0) | 2022.06.21 |