import os
os.remove(“demofile.txt”)
Interviews4 answers
How can files be deleted in Python?
4 Answers
Bidyasagar MishraPosted Sep 2, 2019, 6:08 AM EDT
Using os.remove () method you can remove file
Md SarfarajPosted Jul 23, 2019, 10:22 PM EDT
To delete a file first need to import: import os
then remove function of os will remove the file
example:
import os
os.remove(“filename.txt”)
Arvind SinghPosted Jul 18, 2019, 7:38 PM EDT
To delete a file we do:
os.remove([file_name])
file_name is a string hence should come in inverted commas
Rohit GuptaPosted Jul 9, 2019, 8:13 PM EDT




