+ 1
How to delete from a file?
Sololearn has told us how to read and write to a file in file handling but how to delete something from a file is not known.
6 ответов
+ 1
Hi.
How about reading the file you want to remove parts from, remove the parts, and write the remaining content to file.
It appears you have learned all necessary steps to carry out the operation.
Hope that helps. Cheers. C.
+ 1
Thanks for suggestion ~ swim ~ ,
In fact I am using the same method but was looking for something shorter.
0
Thanks for the suggestion ChrA,
I am using the same method for now but it requires me to open the file 2 times, 2nd time to open with 'w' to truncate the entire file. I was looking for some kind of Short cut.
0
Akash Sil have look at the inplace=1 option here http://pythontesting.net/JUMP_LINK__&&__python__&&__JUMP_LINK/regex-search-replace-examples/