빅

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

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

#!/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-01 조회 1,299
12-05-30 조회 866
12-05-28 조회 850
12-05-23 조회 917
12-05-18 조회 896
12-05-16 조회 975
12-05-16 조회 859
12-05-16 조회 2,173
12-05-16 조회 784
12-05-16 조회 804
12-05-16 조회 1,098
12-05-16 조회 836
12-05-16 조회 686
12-05-15 조회 1,135
12-05-15 조회 721
12-05-15 조회 948
12-05-15 조회 1,558
12-05-15 조회 1,034
12-05-15 조회 670
12-05-14 조회 693
12-05-14 조회 689
12-05-14 조회 602
12-05-14 조회 909
12-05-14 조회 665
12-05-11 조회 1,257