When you create a file object in Python you can read from it in several different ways. Not until today did I understand the difference betweenreadline()andreadlines(). The answer is in the name.readline()reads one
line
character at a time,readlines()reads in the whole file at once and splits it by line.
转载于:https://my.oschina.net/clavin/blog/158596