Read multiple times lines of the same file Python -
I am trying to read several lines of some files in Python.
This is the basic way I am using:
Open as file (name, 'r +') as: in the file for the line: # Do something with the line And it's working fine, but if I want to repeat each row for the second time, even when I am open with my file:
with the file open (name, 'r +'): For the line in the file: # Do something with the line in the file in a few lines: # Do something with Nkti second time And it does not work and off again I need to open, then open my file again to make it work. File as open (name, 'r +') as file
: for file in the row: # some file in the row with some open (name, 'r +') As: Line in file: do something with # line Thanks for the reply!
Use a file to jump in a particular state. However, think about whether it is really necessary to go through the file again or not. Maybe it could be a better option. File in the form of a file (name, 'R +') with the line: file in the row: # Do something with Seek (0): Do something with the # line, second time
Comments
Post a Comment