相关疑难解决方法(0)

如何通过引用传递变量?

Python文档似乎不清楚参数是通过引用还是值传递,以下代码生成未更改的值'Original'

class PassByReference:
    def __init__(self):
        self.variable = 'Original'
        self.change(self.variable)
        print(self.variable)

    def change(self, var):
        var = 'Changed'
Run Code Online (Sandbox Code Playgroud)

有什么我可以通过实际参考传递变量吗?

python reference parameter-passing pass-by-reference

2480
推荐指数
22
解决办法
124万
查看次数

销毁类python的对象

嗨,如果满足 if 语句的条件(在一段时间内满足),我正在尝试销毁一个类对象

global variablecheck

class createobject:
        def __init__(self,userinput):
             self.userinput = input
             self.method()
         
        def method(self):
             while True:
                if self.userinput == variablecheck
                     print('the object created using this class is still alive')
                
                 
                 else:
                    print('user object created using class(createobject) is dead')
                    #what code can i put here to delete the object of this class?


Run Code Online (Sandbox Code Playgroud)

python oop class object self

0
推荐指数
1
解决办法
5374
查看次数