빅

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

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

#!/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

 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
14-09-21 조회 4,349
14-09-21 조회 3,824
14-09-20 조회 3,826
14-09-20 조회 3,732
14-09-20 조회 3,915
14-09-19 조회 3,850
14-09-19 조회 4,004
14-09-19 조회 3,895
14-09-19 조회 3,908
14-09-19 조회 3,833
14-09-19 조회 4,126
14-09-19 조회 3,868
14-09-19 조회 3,917
14-09-19 조회 3,897
14-09-18 조회 3,973
14-09-18 조회 3,937
14-09-18 조회 4,206
14-09-18 조회 4,170
14-09-18 조회 4,184
14-09-18 조회 4,881