Search snippets
Browse Code Answers
FAQ
Usage docs
Log In
Sign Up
Home
Python
how to delete everything on a file python
user67777
Programming language:
Python
2021-06-22 01:18:59
0
Q:
how to delete everything on a file python
Novison
Code:
Python
2021-06-29 16:57:53
f = open('file.txt', 'r+') f.truncate(0) # need '0' when using r+
5
Tags
python
file
how
Related
python code to remove file extension
python delete contents of file
delete contents of directory python
python delete file
how to write to a file in python without deleting all content
python os remove file
delete file python
how to delete file in python
remove empty lines from file python
delete something from list python
python delete all files in directory
if file exists delete python
python delete file with extension
python delete all data from file
clearing all text from a file in python
python removing \n from string
New to Communities?
Join the community