0

How to delete file contents?

Hello there, Can anybody help me how to delete a few contents of a file on which I am working using python. Yes I am talking about data handling in python.

11th Dec 2019, 3:34 PM
Photogenic Gyaan
Photogenic Gyaan - avatar
6 odpowiedzi
+ 1
Photogenic Gyaan once you open a file in write mode, you're deleting all it contents. Iam pretty sure there is no function that deletes specific lines and/or words for you. You have to create one yourself, it's not that hard. If you can't figure it out, feel free to ask again.
11th Dec 2019, 5:37 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Wdym by delete ? We need more info. But basically, you store the file contents in a list variable (I'm assuming you know how to read and write from files), you maie the changes you want on that variable, and then you rewrite the file with the new variable.
11th Dec 2019, 3:40 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Aymane Boukrouh [Unavailable] I meant that like read and write is there any function available to delete what's present in the file I imported to python or any appends that I had made to it
11th Dec 2019, 5:33 PM
Photogenic Gyaan
Photogenic Gyaan - avatar
0
Thank you Aymane Boukrouh [Unavailable] that's what I was trying to know I will trying creating a function.
11th Dec 2019, 5:38 PM
Photogenic Gyaan
Photogenic Gyaan - avatar
0
No problem!
11th Dec 2019, 5:40 PM
Aymane Boukrouh
Aymane Boukrouh - avatar