Search snippets
Browse Code Answers
FAQ
Usage docs
Log In
Sign Up
Home
Python
how to empty a text file in python
Frank Breitling
Programming language:
Python
2021-06-20 01:31:56
0
Q:
how to empty a text file in python
Drew Minto
Code:
Python
2021-02-09 05:42:51
open('file.txt', 'w').close()
4
user215721
Code:
Python
2021-06-23 17:31:49
file = open("sample.txt","r+") file.truncate(0) file.close()
0
Tags
python
file
text
empty
how
text file
Related
remove empty lines from file python
print in text file python
how to check if a string is in a file python
clearing all text from a file in python
python check if a file is empty
python os make empty file
python check empty string
bold text variable in python
python replace text in file
how to make a text file in python
how to open a text file in python
check if string is empty python
how to check empty string in python
open text file in python
check if variable is empty python
python make txt file
how to get python to extract information from a text file
Write a Python program to read an entire text file
New to Communities?
Join the community