def person(name,type):
def read(p):
print(‘%s正在看书‘ %p[‘name‘])
def eat(s):
print(‘%s特别能吃‘ %s[‘type‘])
def init(name,type):
people={
‘name‘:name,
‘type‘ :type,
‘read‘:read,
‘eat‘:eat,
}
return people
res=init(name,type)
return res
person_1=person(‘alex‘,‘小胖子‘)
person_1[‘read‘](person_1)
原文:https://www.cnblogs.com/cxydnxs/p/12322363.html