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

· 13년 전 · 1331

#!/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년 전 조회 559
13년 전 조회 571
13년 전 조회 870
13년 전 조회 606
13년 전 조회 460
13년 전 조회 830
13년 전 조회 962
13년 전 조회 996
13년 전 조회 1,751
13년 전 조회 911
13년 전 조회 492
13년 전 조회 729
13년 전 조회 1,332
13년 전 조회 806
13년 전 조회 443
13년 전 조회 1,368
13년 전 조회 484
13년 전 조회 459
13년 전 조회 388
13년 전 조회 698
13년 전 조회 440
13년 전 조회 899
13년 전 조회 932
13년 전 조회 1,340
13년 전 조회 531
🐛 버그신고