当前位置:主页 > 软件编程 > Python代码 >

python直接访问私有属性的简单方法

时间:2021-04-17 09:55:16 | 栏目:Python代码 | 点击:

实例化对象名._类名__私有属性名

class Flylove:
  
  price = 123
  def __init__(self):
    
    self.__direction = 'go beijing .'
    zIng = 'wait car,many person'
    
if __name__ == '__main__':
  print Flylove.price
  fly = Flylove() 

  print fly._Flylove__direction 

您可能感兴趣的文章:

相关文章