小编Rel*_*pid的帖子

“with io.open”会自动关闭文件吗?

例如:

with io.open('Example.txt','r',encoding='utf-8') as temp:
    ExampleText=temp.readlines()[1]
Run Code Online (Sandbox Code Playgroud)

我是否需要手动关闭它,例如:

with io.open('Example.txt','r',encoding='utf-8') as temp:
    ExampleText=temp.readlines()[1]
temp.close()
Run Code Online (Sandbox Code Playgroud)

python io

3
推荐指数
1
解决办法
5097
查看次数

标签 统计

io ×1

python ×1