如何經過引用傳遞變量? - How do I pass a variable by reference?

問題:

The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original' Python文檔彷佛尚不清楚參數是經過引用仍是經過值傳遞,而且如下代碼產生不變的值「原始」 spa

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

    def change(self, var):
        var = 'Changed'

Is there something I can do to pass the variable by actual reference? 我能夠作些什麼來經過實際引用傳遞變量嗎? .net


解決方案:

參考一: https://stackoom.com/question/48VK/如何經過引用傳遞變量
參考二: https://oldbug.net/q/48VK/How-do-I-pass-a-variable-by-reference
相關文章
相關標籤/搜索