import os #文件读写 不用自动关闭with open('test.txt','r') as f: #一次性读取所有 data = f.read() #print(data)print('---------循环打印------------')with open('test.txt','r') as f: for line in f: if line=='': print('遇到\n换行符') else: #为什么输出是换行? print(line)with open('test.txt'…