Discuss / Python / contextlib 阅读总结

contextlib 阅读总结

Topic source

KeMoing

#1 Created at ... [Delete] [Delete and Lock User]

@contextmanager这个decorator接受一个generator,用yield语句把with ... as var把变量输出出去,然后,with语句就可以正常地工作了

closing()它的作用就是把任意对象变为上下文对象,并支持with语句


  • 1

Reply