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
import os

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

on December 07th, 2018 (11:17 pm)
What masters said
You must sign in to comment!!
All comments
This solution has not been commented yet.
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