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

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

#!/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,297
JavaScript 12-05-22 조회 2,459
기타 12-05-22 조회 1,948
Flash 12-05-21 조회 3,351
PHP 12-05-21 조회 3,362
JavaScript 12-05-20 조회 2,422
Mobile 12-05-19 조회 2,601
PHP 12-05-19 조회 2,221
Linux 12-05-18 조회 2,459
PHP 12-05-18 조회 2,340
Mobile 12-05-18 조회 5,568
MySQL 12-05-17 조회 7,057
Linux 12-05-16 조회 2,144
Linux 12-05-16 조회 1,900
Linux 12-05-16 조회 4,269
Linux 12-05-16 조회 1,727
Linux 12-05-16 조회 1,643
Linux 12-05-16 조회 2,292
Linux 12-05-16 조회 2,297
Linux 12-05-16 조회 2,336
JavaScript 12-05-16 조회 2,197
PHP 12-05-16 조회 2,235
JavaScript 12-05-15 조회 2,584
jQuery 12-05-15 조회 3,807
Linux 12-05-15 조회 3,001
Linux 12-05-15 조회 1,833
Linux 12-05-15 조회 2,456
Linux 12-05-15 조회 2,712
Linux 12-05-15 조회 2,372