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

· 13년 전 · 1354

#!/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년 전 조회 582
13년 전 조회 590
13년 전 조회 894
13년 전 조회 630
13년 전 조회 476
13년 전 조회 860
13년 전 조회 987
13년 전 조회 1,021
13년 전 조회 1,774
13년 전 조회 935
13년 전 조회 519
13년 전 조회 752
13년 전 조회 1,355
13년 전 조회 830
13년 전 조회 466
13년 전 조회 1,396
13년 전 조회 507
13년 전 조회 481
13년 전 조회 409
13년 전 조회 718
13년 전 조회 463
13년 전 조회 918
13년 전 조회 951
13년 전 조회 1,361
13년 전 조회 557