os.path.isfile(): ファイルの存在を調べる
os.path.exists(): ファイルとディレクトリの存在を調べる
os.path.isdir() :ディレクトリの存在を調べる
try, exceptでトラップして存在確認後の処理を分けるといい。
ファイルが存在した場合に消すプログラム
import os
file="c:/temp/drawrect.txt"
if os.path.isfile(file):
os.remove(file)
else:
print file ,"is not exist"