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

· 13년 전 · 1368

#!/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년 전 조회 595
13년 전 조회 599
13년 전 조회 902
13년 전 조회 641
13년 전 조회 494
13년 전 조회 873
13년 전 조회 1,001
13년 전 조회 1,028
13년 전 조회 1,787
13년 전 조회 944
13년 전 조회 530
13년 전 조회 769
13년 전 조회 1,369
13년 전 조회 848
13년 전 조회 478
13년 전 조회 1,411
13년 전 조회 513
13년 전 조회 493
13년 전 조회 419
13년 전 조회 729
13년 전 조회 469
13년 전 조회 930
13년 전 조회 968
13년 전 조회 1,371
13년 전 조회 575