if f=open('test.txt','r') == True:  이나

if not f=open('test.txt','r'):     은 동작 할 수가 없다.



따라서 어떠한 파일을 읽기모드로 열고자 할떄 그 파일의 존재 여부를 가지고 할 수있는 문장은 아래와 같다.

try:

f=open('test.txt','r')

print f.read()

except IOError:

print "Don't Exist File..."

'Programming > Python' 카테고리의 다른 글

Code Injection by Python  (1) 2015.03.26
DLL Injection API by Python  (0) 2015.03.25
Key_logger.py in GitHub  (0) 2015.03.05
Del_file.py in GitHub  (0) 2015.03.02
Setup.py // Py2Exe 사용법  (0) 2015.02.26