苗火 Nicholas
[python]An example of with_as
2022-12-5 萧
class newc:
def __enter__(self):
print("enter of newc\n")
return self

def __exit__(self,type,value,trace):
print("exit of newc\n")
print("type:", type)
print("value:", value)
print("trace:", trace)

def fun(self):
print("fun in newc:\n")

with newc() as ppt:
ppt.fun()
print("exit\n")
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容