빅

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

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

#!/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 조회 988
12-05-16 조회 871
12-05-16 조회 2,187
12-05-16 조회 792
12-05-16 조회 812
12-05-16 조회 1,108
12-05-16 조회 848
12-05-16 조회 699
12-05-16 조회 1,074
12-05-16 조회 1,204
12-05-15 조회 1,231
12-05-15 조회 1,992
12-05-15 조회 1,150
12-05-15 조회 733
12-05-15 조회 960
12-05-15 조회 1,571
12-05-15 조회 1,047
12-05-15 조회 680
12-05-15 조회 1,600
12-05-14 조회 699
12-05-14 조회 701
12-05-14 조회 610
12-05-14 조회 921
12-05-14 조회 678
12-05-14 조회 1,130