Advertisement
elena1234

Delete file in Python

Feb 10th, 2022
1,068
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.14 KB | None | 0 0
  1. import os
  2.  
  3. try:
  4.     os.remove("my_new_file")
  5.     print("Deleted!")
  6. except FileNotFoundError:
  7.     print("File already deleted!")
  8.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement