[3.11] Pythonでのステートメントで

。1  /ユーザー/ binに/ envをPythonの!
2  - * -コーディング:UTF-8 - * - 。
3。 
4。  コンテキストマネージャプロトコル
5。 
6。 
7つの。 クラスサンプル:
 8。     DEF  __enter__ (セルフ):
 9。         印刷' 入力' 10          リターン自己
 11。 
12は、     DEF  __exit__ (セルフ、exc_type、exc_val、exc_tb):
 13である         プリント' 終了' 14  
15      @staticmethod
 16      DEFのdo_something():
17          プリント' do_something ' 18  
19  
20  試料と試料との():
 21      sample.do_something()
入力
do_something 
の出口を

  

おすすめ

転載: www.cnblogs.com/zydeboke/p/11239343.html