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

· 13년 전 · 2442

#!/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,663
Linux 13년 전 조회 4,021
Linux 13년 전 조회 1,494
Linux 13년 전 조회 1,402
Linux 13년 전 조회 2,048
Linux 13년 전 조회 2,035
Linux 13년 전 조회 2,088
JavaScript 13년 전 조회 1,932
PHP 13년 전 조회 1,971
JavaScript 13년 전 조회 2,343
jQuery 13년 전 조회 3,576
Linux 13년 전 조회 2,709
Linux 13년 전 조회 1,575
Linux 13년 전 조회 2,234
Linux 13년 전 조회 2,443
Linux 13년 전 조회 2,129
Linux 13년 전 조회 1,713
jQuery 13년 전 조회 3,252
Linux 13년 전 조회 1,446
Linux 13년 전 조회 1,542
Linux 13년 전 조회 1,705
Linux 13년 전 조회 2,152
Linux 13년 전 조회 1,901
jQuery 13년 전 조회 2,250
기타 13년 전 조회 2,701
jQuery 13년 전 조회 3,360
PHP 13년 전 조회 1,833
jQuery 13년 전 조회 8,368
Linux 13년 전 조회 2,661
Linux 13년 전 조회 1,541
🐛 버그신고