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

· 13년 전 · 1344

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

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

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
13년 전 조회 573
13년 전 조회 585
13년 전 조회 887
13년 전 조회 619
13년 전 조회 471
13년 전 조회 845
13년 전 조회 974
13년 전 조회 1,011
13년 전 조회 1,765
13년 전 조회 924
13년 전 조회 508
13년 전 조회 744
13년 전 조회 1,345
13년 전 조회 819
13년 전 조회 459
13년 전 조회 1,385
13년 전 조회 497
13년 전 조회 474
13년 전 조회 402
13년 전 조회 711
13년 전 조회 456
13년 전 조회 913
13년 전 조회 945
13년 전 조회 1,356
13년 전 조회 545