python中的self相当于C++中的this指针,指示的是其本身对象
例如
1 high = 172
2
3 class PrintIn:
4 def __init__(self,high1):
5 self.high = high1
6 if(self.high < 160):
7 print "haaa,So short that you don't do this job"
8 return
9 elif(self.high > 200):
10 print "Mother fucker,are you Yao Ming?"
11 else:
12 print "O'ye,you can do this job very well"
13 def printInfo(self,age1):
14 self.age = age1
15 print (self.age,self.high)
16
17 if __name__ == '__main__':
18 p = PrintIn(201)
19 p.printInfo(26)
20 '''
21 PrintIn.printInfo(p,26)22 '''
原文链接: https://www.cnblogs.com/jeromesunny/p/3183760.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/95438
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!