python readline in the "pit"

      Today, with python handle file data with readline () method to read the rows, but the next logical in, but also how to get any value, toss a half, it turned out to be readline () will read data comes newline. This time is simple to remove by newline strip () function. Pseudo-code as follows:

with open(fpath, 'r') as f:
    line = f.readline()
  line = line.strip('\n')
   # do something

 As treatment, baffling problem would not arise.


Guess you like

Origin blog.51cto.com/jack88/2448050