[python]os.path.exists() 파일 존재 체크하기

· 13년 전 · 2457

#!/usr/bin/python

import os

if not os.path.exists("./test.txt"):
        print "test.txt file not exist"

if os.path.exists("./test.txt"):
        print "test.text file exist"

root@byoungguk-desktop:~# ./existtest.py 
test.txt file not exist
root@byoungguk-desktop:~# touch test.txt
root@byoungguk-desktop:~# ./existtest.py 
test.text file exist

 
|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
Linux 13년 전 조회 1,670
Linux 13년 전 조회 4,026
Linux 13년 전 조회 1,501
Linux 13년 전 조회 1,414
Linux 13년 전 조회 2,058
Linux 13년 전 조회 2,046
Linux 13년 전 조회 2,099
JavaScript 13년 전 조회 1,942
PHP 13년 전 조회 1,980
JavaScript 13년 전 조회 2,348
jQuery 13년 전 조회 3,587
Linux 13년 전 조회 2,724
Linux 13년 전 조회 1,588
Linux 13년 전 조회 2,237
Linux 13년 전 조회 2,458
Linux 13년 전 조회 2,144
Linux 13년 전 조회 1,724
jQuery 13년 전 조회 3,268
Linux 13년 전 조회 1,457
Linux 13년 전 조회 1,557
Linux 13년 전 조회 1,713
Linux 13년 전 조회 2,163
Linux 13년 전 조회 1,915
jQuery 13년 전 조회 2,260
기타 13년 전 조회 2,712
jQuery 13년 전 조회 3,367
PHP 13년 전 조회 1,839
jQuery 13년 전 조회 8,382
Linux 13년 전 조회 2,667
Linux 13년 전 조회 1,548
🐛 버그신고