2004年03月23日 星期二 09:20
补充:如果在类中: class A: cc='78910' def __init__(self): self.aa='1234' bb='4567' 上面的self.aa属于类A的实例的属性,bb是构造器函数__init__()的局部变量,cc是类A的属性(不用实例化就可以访问:print A.cc) ----- Original Message ----- From: 0.706 To: python-chinese at lists.python.cn Sent: Tuesday, March 23, 2004 9:01 AM Subject: Re: [python-chinese]关于 self poly,您好! 关键在前面的self,这说明了该变量是属于实例的。如果前面没有self,才是局部变量. ======== 2004-03-23 08:56:58 您在来信中写道: ======== 我看见书上的代码,比如在__init__中用 self.aa="" self.bb="" 后,这个aa,bb应该是只属于__init__的局部变量嘛,为什么在其他方法中还可以用self.aa来调用呢,这不是成了全局变量?有点没有搞懂,请指点 = = = = = = = = = = = = = = = = = = = = = = 致 礼! 0.706 0.706 at 163.com 2004-03-23 ------------------------------------------------------------------------------ _______________________________________________ python-chinese list python-chinese at lists.python.cn http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040323/f67ff6b1/attachment.html
Zeuux © 2024
京ICP备05028076号