【发布时间】:2022-06-13 12:42:14
【问题描述】:
请帮我理解如何使用这个语句并举个例子(没有open()方法)。
def say_hello(text:str):
return print(text)
with say_hello("Hello") as hello:
hello
【问题讨论】:
标签: python python-3.x with-statement python-3.9 python-3.10
请帮我理解如何使用这个语句并举个例子(没有open()方法)。
def say_hello(text:str):
return print(text)
with say_hello("Hello") as hello:
hello
【问题讨论】:
标签: python python-3.x with-statement python-3.9 python-3.10
标准约定应该是
hello = say_hello("Hello")
# your code here
hello.close()
【讨论】: