Situatie
To delete a file with this script, we can use the os
module.It’s recommended to check with a conditional if the file exist before calling the remove()
function from the module:
import os
if os.path.exists("<file_path>"):
os.remove("<file_path>")
else:
<code>
Backup
Example:
import os
if os.path.exists("famous_actors.txt"):
os.remove("famous_actors.txt")
else:
print("This file doesn't exist")
Leave A Comment?