Solution: Most pythonic way to delete a file which may not exist

Development | Programming languages
Description
I want to delete the file filename if it exists.
Attachments
No attachments
Solutions
Description
import os

if os.path.exists("filename.txt"): os.remove("filename.txt")

on December 07th, 2018 (11:17 pm)
All coments
This solution has not been commented yet.
You must sign in to comment!! LOGIN
We use cookies to give you the best possible experience on our site. By continuing to use the site you agree to our use of cookies. Find out more Accept