+ 1

Remove and edit strings from python file

https://code.sololearn.com/cA769D2Qd3Vg/?ref=app How would you remove and edit a string in a python file?

7th Mar 2019, 7:37 PM
farhan bhatti
farhan bhatti - avatar
2 Respostas
+ 4
You can remove a file by: import os os.remove("filename") You can modify a file by: file = open("filename", "w") #but it clears the file content first file.write("new content") file.close() You can also modify a file by: file = open("filename", "a") #It doesn't clear the content file.write("new content") #adds some new content in the end of the file. file.close()
8th Mar 2019, 11:21 AM
Seb TheS
Seb TheS - avatar
0
im trying to look for a runner and remove all their details or edit their details as you can see from the functions
8th Mar 2019, 4:45 PM
farhan bhatti
farhan bhatti - avatar