如何使用另一个Python返回变量

问题描述 投票:0回答:1

在迅速地工作了很多之后,我习惯了以下语法:

private var __privateVar = 100 // Not accessible from outside the Class
public var public_var: Int = {
    return __privateVar // Returns __privateVar, and is get-only variable
}

有没有一种方法可以在python 3中重现?非常感谢

python class private public
1个回答
-1
投票
x = 100
y = x
print(y)

字符限制。

© www.soinside.com 2019 - 2024. All rights reserved.