版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。#类的嵌套 class parent: def __init__(self): self.name = "parent" def getName(self): print(self.name) class child: def __init__(self): self.name = "child" def getName(self): print(self.name) p = parent() p.getName() c = p.child() c.getName()
输出为:
parent child