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

· 2012-05-15 (화) 16:12:17 · 2710

#!/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

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

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
jQuery 12-05-22 조회 7,589
MySQL 12-05-22 조회 3,296
JavaScript 12-05-22 조회 2,457
기타 12-05-22 조회 1,948
Flash 12-05-21 조회 3,350
PHP 12-05-21 조회 3,362
JavaScript 12-05-20 조회 2,420
Mobile 12-05-19 조회 2,601
PHP 12-05-19 조회 2,221
Linux 12-05-18 조회 2,458
PHP 12-05-18 조회 2,339
Mobile 12-05-18 조회 5,567
MySQL 12-05-17 조회 7,056
Linux 12-05-16 조회 2,143
Linux 12-05-16 조회 1,897
Linux 12-05-16 조회 4,267
Linux 12-05-16 조회 1,727
Linux 12-05-16 조회 1,641
Linux 12-05-16 조회 2,292
Linux 12-05-16 조회 2,297
Linux 12-05-16 조회 2,335
JavaScript 12-05-16 조회 2,196
PHP 12-05-16 조회 2,233
JavaScript 12-05-15 조회 2,583
jQuery 12-05-15 조회 3,807
Linux 12-05-15 조회 2,999
Linux 12-05-15 조회 1,830
Linux 12-05-15 조회 2,454
Linux 12-05-15 조회 2,711
Linux 12-05-15 조회 2,372