import contextlib
import time

@contextlib.contextmanager
def open(file_name):
    print('statrt',time.time())
    yield
    print('end time',time.time())


with open('zy.txt') as f_opened:
    print('file processing')
程序是经过with open 调用open函数。

 

posted on 2022-09-28 10:29  topass123  阅读(15)  评论(0编辑  收藏  举报