如何在Python对象中访问Python对象?

可以按以下方式访问对象中的对象

示例

class P:
 def __init__(self):
   self.w = Q()class Q:
 def __init__(self):
  self.list = [3,4,5]
 def function(self):
  self.list[2] = 7
y = P()f = [y]
print f[0].w.function()
print f[0].w.list

输出结果

输出为

None
[3, 4, 7]