Python—— 22.with

关键词 with保证如文件类的对象在使用完之后的对象置空(清理)。

with open("myfile.txt") as f:
    for line in f:
        print(line, end="")

.
————Blueicex 2020/2/22 22:39 [email protected]

发布了118 篇原创文章 · 获赞 1 · 访问量 4492

猜你喜欢

转载自blog.csdn.net/blueicex2017/article/details/104451267