我不确定 Bla.lol() 如何修改提供给它的参数 a,但它可以更改属性 Bla.a或self.a从对象内部引用它,该对象最初具有a分配给它的参数值。我们可以让函数lol为属性分配一个新值a,在这种情况下,我将假设a它是一个字符串,并使用以下短语扩展该字符串' has been altered':>>> class Bla:... def __init__(self, a):... self.a = a... ... def lol(self):... self.a += ' has been altered'... >>> instance = Bla('the arg a')>>> instance.a # check a'the arg a'>>> instance.lol() # modifies a>>> instance.a # check a again'the arg a has been altered'>>> instance.lol() # we can alter it again, as many times as we run the function>>> instance.a # and see it has been altered a second time'the arg a has been altered has been altered'