Non-class attributes of different python methods cannot be modified uniformly

class A:
    def methoda(self):
        a = {
    
    'a': 1}
        self.methodb(a)
        print(a)
    def methodb(self, value):
        value = {
    
    'b': 2}

if __name__ == '__main__':
    instance = A()
    instance.methoda()
{
    
    'a': 1}

You can see that the output is still the original a, and has not been changed by methodb.

Guess you like

Origin blog.csdn.net/qq_42648305/article/details/112792579