目录
内部类怎么引用外部类的类属性?调用外部类的类方法?
1. 引用外部类的类属性
例子:
class Out:
def __init__(self):
self.ticket = ''
def get(self):
self.ticket = 'zfhbcsibvsof'
class In:
def __init__(self):
out = Out()
out.get()
self.ticket = out.ticket
执行结果:
zfhbcsibvsof