빅

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

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

#!/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,404건

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

+
분류 제목 글쓴이 날짜 조회
MySQL 12-05-23 조회 3,059
jQuery 12-05-22 조회 7,623
MySQL 12-05-22 조회 3,328
JavaScript 12-05-22 조회 2,490
기타 12-05-22 조회 1,977
Flash 12-05-21 조회 3,387
PHP 12-05-21 조회 3,403
JavaScript 12-05-20 조회 2,451
Mobile 12-05-19 조회 2,634
PHP 12-05-19 조회 2,252
Linux 12-05-18 조회 2,492
PHP 12-05-18 조회 2,367
Mobile 12-05-18 조회 5,598
MySQL 12-05-17 조회 7,106
Linux 12-05-16 조회 2,170
Linux 12-05-16 조회 1,928
Linux 12-05-16 조회 4,307
Linux 12-05-16 조회 1,758
Linux 12-05-16 조회 1,681
Linux 12-05-16 조회 2,320
Linux 12-05-16 조회 2,322
Linux 12-05-16 조회 2,360
JavaScript 12-05-16 조회 2,228
PHP 12-05-16 조회 2,269
JavaScript 12-05-15 조회 2,612
jQuery 12-05-15 조회 3,834
Linux 12-05-15 조회 3,039
Linux 12-05-15 조회 1,867
Linux 12-05-15 조회 2,490
Linux 12-05-15 조회 2,754