Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to read then overwrite a file with python with truncate

 pythonCopywith open('myFolder/myfile.txt','r+') as myfile:
    data = myfile.read()
    myfile.seek(0)
    myfile.write('newData')
    myfile.truncate()
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #read #overwrite #file #python #truncate
ADD COMMENT
Topic
Name
9+3 =