빅

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

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

#!/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 조회 985
12-05-16 조회 869
12-05-16 조회 2,185
12-05-16 조회 791
12-05-16 조회 812
12-05-16 조회 1,107
12-05-16 조회 846
12-05-16 조회 698
12-05-16 조회 1,074
12-05-16 조회 1,204
12-05-15 조회 1,230
12-05-15 조회 1,992
12-05-15 조회 1,147
12-05-15 조회 732
12-05-15 조회 958
12-05-15 조회 1,568
12-05-15 조회 1,045
12-05-15 조회 679
12-05-15 조회 1,600
12-05-14 조회 699
12-05-14 조회 699
12-05-14 조회 609
12-05-14 조회 919
12-05-14 조회 677
12-05-14 조회 1,130