빅

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

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

#!/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-06-02 조회 916
12-06-02 조회 1,586
12-06-01 조회 1,366
12-05-25 조회 1,636
12-05-25 조회 808
12-05-21 조회 1,410
12-05-19 조회 875
12-05-18 조회 1,153
12-05-16 조회 1,210
12-05-11 조회 773
12-05-07 조회 915
12-05-05 조회 1,129
12-05-05 조회 1,027
12-05-05 조회 912
12-05-04 조회 1,967
12-05-03 조회 1,089
12-04-30 조회 1,074
12-04-26 조회 2,011
12-04-25 조회 901
12-04-23 조회 1,067
12-04-23 조회 938
12-04-20 조회 2,241
12-04-20 조회 1,166
12-04-18 조회 868
12-04-17 조회 1,504