빅

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

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

#!/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,605
MySQL 12-05-22 조회 3,306
JavaScript 12-05-22 조회 2,471
기타 12-05-22 조회 1,960
Flash 12-05-21 조회 3,364
PHP 12-05-21 조회 3,384
JavaScript 12-05-20 조회 2,433
Mobile 12-05-19 조회 2,614
PHP 12-05-19 조회 2,235
Linux 12-05-18 조회 2,469
PHP 12-05-18 조회 2,350
Mobile 12-05-18 조회 5,584
MySQL 12-05-17 조회 7,088
Linux 12-05-16 조회 2,151
Linux 12-05-16 조회 1,912
Linux 12-05-16 조회 4,286
Linux 12-05-16 조회 1,735
Linux 12-05-16 조회 1,655
Linux 12-05-16 조회 2,303
Linux 12-05-16 조회 2,306
Linux 12-05-16 조회 2,347
JavaScript 12-05-16 조회 2,208
PHP 12-05-16 조회 2,251
JavaScript 12-05-15 조회 2,590
jQuery 12-05-15 조회 3,816
Linux 12-05-15 조회 3,010
Linux 12-05-15 조회 1,842
Linux 12-05-15 조회 2,465
Linux 12-05-15 조회 2,725
Linux 12-05-15 조회 2,385