你试过这个unregisterWith方法吗?import QuantLib as qlflag = Nonedef raiseFlag(): global flag flag = 1me = ql.SimpleQuote(0.0)obs = ql.Observer(raiseFlag)obs.registerWith(me)me.setValue(3.14)if not flag: print("Case 1: Observer was not notified of market element change")flag = Noneobs.unregisterWith(me)me.setValue(3.14)if not flag: print("Case 2: Observer was not notified of market element change")