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.
6 ответов
+ 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.
+ 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.
+ 1
I would suggest using google. I found this in 10 seconds: https://stackoverflow.com/questions/17126037/how-to-delete-only-the-content-of-file-in-JUMP_LINK__&&__python__&&__JUMP_LINK/17126137
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
0
Thank you Aymane Boukrouh [Unavailable] that's what I was trying to know
I will trying creating a function.
0
No problem!