Back
I want to execute the code that will delete the file if it is existing in that directory. I have executed the code:
if os.path.exists(filename): os.remove(filename)
if os.path.exists(filename):
os.remove(filename)
You can refer to the below code in Python:
try: os.remove(filename)except OSError: pass
try:
except OSError:
pass
30.9k questions
32.9k answers
500 comments
665 users