1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| def readline_1(): with open(expanduser('some.txt'), 'r') as file: line: str = file.readline() print('readline_1:', type(line)) while line: print('readline_1:', type(line)) line = file.readline()
def readline_2(): with open(expanduser('some.txt'), 'r') as logfile: while True: line: str = logfile.readline() if line == '': break elif line: print('readline_2:', type(line))
|