Home  »  CodeSnippets   »   Python Delete all Text in Text File

Python Delete all Text in Text File

Posted: February 6, 2022 | by Site Host

f = open("filename.txt", "r+")
f.truncate(0)
f.close()

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Share it!

See also  How to Read a File in Python