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

· 13년 전 · 2439

#!/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,661
Linux 13년 전 조회 4,015
Linux 13년 전 조회 1,491
Linux 13년 전 조회 1,399
Linux 13년 전 조회 2,046
Linux 13년 전 조회 2,032
Linux 13년 전 조회 2,087
JavaScript 13년 전 조회 1,930
PHP 13년 전 조회 1,967
JavaScript 13년 전 조회 2,339
jQuery 13년 전 조회 3,573
Linux 13년 전 조회 2,705
Linux 13년 전 조회 1,572
Linux 13년 전 조회 2,231
Linux 13년 전 조회 2,440
Linux 13년 전 조회 2,126
Linux 13년 전 조회 1,710
jQuery 13년 전 조회 3,252
Linux 13년 전 조회 1,443
Linux 13년 전 조회 1,540
Linux 13년 전 조회 1,702
Linux 13년 전 조회 2,149
Linux 13년 전 조회 1,900
jQuery 13년 전 조회 2,248
기타 13년 전 조회 2,700
jQuery 13년 전 조회 3,360
PHP 13년 전 조회 1,829
jQuery 13년 전 조회 8,366
Linux 13년 전 조회 2,655
Linux 13년 전 조회 1,536
🐛 버그신고