若要自行建立context manager,只要定義好類別的 __enter__ 與 __exit__ 兩個方法函數即可, with 在剛開始執行時,會執行 __enter__ 這個函數,傳回 ...
確定! 回上一頁