私有方法 练习

  1 class Dog:
  2 
  3     #私有方法
  4     def __test(self):         #私有方法 ‘前面加————’
  5         print('--------出货中-------')
  6 
  7     #共有方法
  8     def test(self,money):
  9         if money>10000:
 10             self.__test()      #类的里面调用类的其它方法
 11         else:
 12             print('余额不足')
 13 
 14 dog = Dog()
 15 dog.test(10)
 16 
原文地址:https://www.cnblogs.com/Smalllv/p/8886953.html