Python: Most optimal way to read file line by line
问题 I have a large input file I need to read from so I don't want to use enumerate or fo.readlines() . for line in fo: in the traditional way won't work and I'll state why, but I feel some modification to that is what I need right now. Consider the following file: input_file.txt: 3 # No of tests that will follow 3 # No of points in current test 1 # 1st x-coordinate 2 # 2nd x-coordinate 3 # 3rd x-coordinate 2 # 1st y-coordinate 4 # 2nd y-coordinate 6 # 3rd y-coordinate ... What I need is to be