빅

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

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

#!/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 조회 972
12-05-16 조회 855
12-05-16 조회 2,171
12-05-16 조회 780
12-05-16 조회 803
12-05-16 조회 1,092
12-05-16 조회 832
12-05-16 조회 682
12-05-16 조회 1,059
12-05-16 조회 1,189
12-05-15 조회 1,209
12-05-15 조회 1,974
12-05-15 조회 1,133
12-05-15 조회 716
12-05-15 조회 945
12-05-15 조회 1,556
12-05-15 조회 1,032
12-05-15 조회 666
12-05-15 조회 1,590
12-05-14 조회 687
12-05-14 조회 687
12-05-14 조회 599
12-05-14 조회 907
12-05-14 조회 659
12-05-14 조회 1,119