with open(path,'r') as f: lines = f.read().splitlines for line in lines print(line)splitlines就相当于将文件分成了行,然后还是需要遍历来获取所有的行。