with open as f是什么意思

2026年09月22日 22:23
有2个网友回答
网友(1):

with open as f
以开放为F
with open as f
以开放为F

网友(2):

以with open('./data.txt','w',encoding='utf-8') as fp:

fp.write('hello world')为例
将open的部分看为fp之后用fp.write便可以将hello world字符串写入fp中也就是open打开的data.txt
我的个人理解,如有不对,欢迎指正,谢谢。