빅

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

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

#!/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 조회 994
12-05-16 조회 879
12-05-16 조회 2,193
12-05-16 조회 798
12-05-16 조회 825
12-05-16 조회 1,116
12-05-16 조회 852
12-05-16 조회 709
12-05-16 조회 1,079
12-05-16 조회 1,210
12-05-15 조회 1,248
12-05-15 조회 2,001
12-05-15 조회 1,160
12-05-15 조회 743
12-05-15 조회 968
12-05-15 조회 1,579
12-05-15 조회 1,056
12-05-15 조회 688
12-05-15 조회 1,608
12-05-14 조회 708
12-05-14 조회 708
12-05-14 조회 618
12-05-14 조회 928
12-05-14 조회 686
12-05-14 조회 1,138