类的实例化过程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了类的实例化过程相关的知识,希望对你有一定的参考价值。
例代码:
1 class Dog(object): 2 3 def __init__(self,name): 4 self.Name = name 5 6 def shout(self): 7 print("%s wang...wang...wang!" %self.Name) 8 9 10 11 a = Dog(‘gg‘) #Dog(a,‘gg‘)将a传给self,相当于a.Name = name 12 a_2 = Dog(‘yy‘) 13 14 a.shout() #将a.shout(d)穿给shout(self) 15 a_2.shout()

代码流程图:
以上是关于类的实例化过程的主要内容,如果未能解决你的问题,请参考以下文章