python delete all data from file

Do you want to know the information regarding “python delete all data from file”. If yes, you’re in the correct article.

python delete all data from file

fileVariable = open('textDocName.txt', 'r+')
fileVariable.truncate(0)
fileVariable.close()
file = open("sample.txt","r+")
file.truncate(0)
file.close()

Final Words

I hope this post helps you to know about “python delete all data from file”. If you have any doubts regarding this article please let us know via the comment section. Share this article with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment