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函数。
本文来自博客园,作者:topass123,转载请注明原文链接:https://www.cnblogs.com/topass123/p/16737152.html