How can files be deleted in Python?
Dinesh Beniwal
Select an image from your device to upload
To delete a file we do:
os.remove([file_name])
file_name is a string hence should come in inverted commas
import osos.remove(“demofile.txt”)
To delete a file first need to import: import osthen remove function of os will remove the fileexample:import osos.remove(“filename.txt”)