빅

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

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

#!/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,610
MySQL 12-05-22 조회 3,310
JavaScript 12-05-22 조회 2,476
기타 12-05-22 조회 1,962
Flash 12-05-21 조회 3,370
PHP 12-05-21 조회 3,391
JavaScript 12-05-20 조회 2,437
Mobile 12-05-19 조회 2,619
PHP 12-05-19 조회 2,238
Linux 12-05-18 조회 2,475
PHP 12-05-18 조회 2,357
Mobile 12-05-18 조회 5,591
MySQL 12-05-17 조회 7,093
Linux 12-05-16 조회 2,154
Linux 12-05-16 조회 1,916
Linux 12-05-16 조회 4,293
Linux 12-05-16 조회 1,741
Linux 12-05-16 조회 1,660
Linux 12-05-16 조회 2,305
Linux 12-05-16 조회 2,310
Linux 12-05-16 조회 2,349
JavaScript 12-05-16 조회 2,210
PHP 12-05-16 조회 2,253
JavaScript 12-05-15 조회 2,595
jQuery 12-05-15 조회 3,822
Linux 12-05-15 조회 3,020
Linux 12-05-15 조회 1,845
Linux 12-05-15 조회 2,472
Linux 12-05-15 조회 2,731
Linux 12-05-15 조회 2,392