빅

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

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

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

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

팁게시판

6,077건

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
12-05-16 조회 1,022
12-05-16 조회 911
12-05-16 조회 2,218
12-05-16 조회 821
12-05-16 조회 841
12-05-16 조회 1,132
12-05-16 조회 867
12-05-16 조회 722
12-05-16 조회 1,098
12-05-16 조회 1,235
12-05-15 조회 1,264
12-05-15 조회 2,016
12-05-15 조회 1,177
12-05-15 조회 761
12-05-15 조회 985
12-05-15 조회 1,595
12-05-15 조회 1,071
12-05-15 조회 706
12-05-15 조회 1,628
12-05-14 조회 727
12-05-14 조회 726
12-05-14 조회 637
12-05-14 조회 948
12-05-14 조회 710
12-05-14 조회 1,156