Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

How to delete a file:Check if a file exist before you delete a file - Python Code Bank


How to delete a file:Check if a file exist before you delete a file
After hacking into a passworded system you can read,delete a file if neccessary.
                Delete a file:
use o(s.remove() function
E.g. Remove the file 'demofile.txt';

Code: import os
os.remove("demofile.txt")

Check if a file exist before delete:

Code:import os
if os.path.exists("demofile.txt");
os.remove("demofile.txt")
else:
Print("The file does not exist") 
            
Comments
Sorry but there are no comments to display