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

· 13년 전 · 2441

#!/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,662
Linux 13년 전 조회 4,019
Linux 13년 전 조회 1,494
Linux 13년 전 조회 1,401
Linux 13년 전 조회 2,047
Linux 13년 전 조회 2,034
Linux 13년 전 조회 2,087
JavaScript 13년 전 조회 1,931
PHP 13년 전 조회 1,969
JavaScript 13년 전 조회 2,342
jQuery 13년 전 조회 3,575
Linux 13년 전 조회 2,709
Linux 13년 전 조회 1,575
Linux 13년 전 조회 2,232
Linux 13년 전 조회 2,442
Linux 13년 전 조회 2,128
Linux 13년 전 조회 1,711
jQuery 13년 전 조회 3,252
Linux 13년 전 조회 1,445
Linux 13년 전 조회 1,541
Linux 13년 전 조회 1,705
Linux 13년 전 조회 2,151
Linux 13년 전 조회 1,901
jQuery 13년 전 조회 2,250
기타 13년 전 조회 2,701
jQuery 13년 전 조회 3,360
PHP 13년 전 조회 1,831
jQuery 13년 전 조회 8,367
Linux 13년 전 조회 2,660
Linux 13년 전 조회 1,541
🐛 버그신고