在Python中,类中的受保护变量和公共变量有什么区别
class A:
def __init__(self):
self._protected="protected"
self.__private="private"
self.public="public"
>>> a = A()
>>> a.public
'public'
>>> a._protected
'protected'
>>>
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下其中的区别,并指导我如何在 python 中使用受保护的变量吗[如果我的方法用法是错误的]
提前致谢。