# with代码块执行完毕后,内部会自动关闭并释放文件资源 with open('wuenda.txt','r',encoding='utf-8') as f1, \ open('test.txt','r',encoding='utf-8') as f2: for line in f1: print(line) for line in f2: print(line)
本文共 278 字,大约阅读时间需要 1 分钟。
# with代码块执行完毕后,内部会自动关闭并释放文件资源 with open('wuenda.txt','r',encoding='utf-8') as f1, \ open('test.txt','r',encoding='utf-8') as f2: for line in f1: print(line) for line in f2: print(line)
转载于:https://www.cnblogs.com/ceceliahappycoding/p/8337946.html