Skip to main content
 首页 » 编程设计

python之如何在 Python 中绑定(bind)常量参数

2025年05月04日10bhlsheji

<分区>

我有一个类似于

的类
class C: 
    def __init__(self, a): 
        self.a = a 
    def noParam(self): 
        return self.a 
    def withParam(self, b) 
        return self.a + b 
instC = C(5.) 

我需要将类的特定实例的方法作为参数传递。传递 instC.noParam 工作正常,但我如何通过 instC.withParam 和 b 总是等于说 239 ?谢谢。