Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to delete everything on a file python

f = open('file.txt', 'r+')
f.truncate(0) # need '0' when using r+
Comment

PREVIOUS NEXT
Code Example
Python :: remove substring python 
Python :: suppress warning jupyter notebook 
Python :: how to change number of steps in tensorflow object detection api 
Python :: save plot as image python matplotlib 
Python :: train test validation sklearn 
Python :: np zeros in more dimensions 
Python :: django update increment 
Python :: python format float 
Python :: python local server command 
Python :: previous value list loop python 
Python :: concat dictionary of dataframes 
Python :: python replace multiple spacis with spaces 
Python :: sort json python 
Python :: char list 
Python :: how to drop a column by name in pandas 
Python :: how to print dataframe in python without index 
Python :: python convert html to text 
Python :: return column of matrix numpy 
Python :: python remove duplicates from list 
Python :: python set current working directory to script location python 
Python :: prime number program in python print 1 to 100 
Python :: what is a module computer science 
Python :: convert series to datetime 
Python :: pyqt5 display math 
Python :: add percentage column pandas 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: open text file in python 
Python :: bs4 table examples python 
Python :: get all count rows pandas 
Python :: sqlalchemy validation 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =