Python | Delete a file
Using command os.remove(file_name)
Use the os module to delete a file, we need to first import it, and then use the remove() function provided by the module to delete the file. It takes the file path as a parameter.
import os
file_path = <file_path>
if os.path.isfile(file_path):
os.remove(file_path)