Passing an integer by reference in Python

后端 未结 11 1928
天命终不由人
天命终不由人 2020-11-22 12:29

How can I pass an integer by reference in Python?

I want to modify the value of a variable that I am passing to the function. I have read that everything in Python i

11条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 13:01

    class PassByReference:
        def Change(self, var):
            self.a = var
            print(self.a)
    s=PassByReference()
    s.Change(5)     
    

提交回复
热议问题