03 with上下文管理

"""
@作者: egon老湿
@微信:18611453110
@专栏: https://zhuanlan.zhihu.com/c_1189883314197168128
"""
# 文件对象又称为文件句柄

# with open('a.txt',mode='rt') as f1: # f1=open('a.txt',mode='rt')
# res=f1.read()
# print(res)


with open('a.txt',mode='rt') as f1,\
open('b.txt',mode='rt') as f2:
res1=f1.read()
res2=f2.read()
print(res1)
print(res2)

# f1.close()
# f2.close()

posted on   小小小传说  阅读(11)  评论(0编辑  收藏  举报

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示