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

· 13년 전 · 1342

#!/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년 전 조회 570
13년 전 조회 583
13년 전 조회 885
13년 전 조회 617
13년 전 조회 470
13년 전 조회 843
13년 전 조회 971
13년 전 조회 1,010
13년 전 조회 1,763
13년 전 조회 923
13년 전 조회 505
13년 전 조회 743
13년 전 조회 1,343
13년 전 조회 818
13년 전 조회 457
13년 전 조회 1,384
13년 전 조회 495
13년 전 조회 471
13년 전 조회 400
13년 전 조회 709
13년 전 조회 455
13년 전 조회 910
13년 전 조회 942
13년 전 조회 1,354
13년 전 조회 543