filename = 'log.txt' with open(filename) as file_object: # python按行读取文件 for line in file_object: print(line)