2020-2-10 11:02作者: 来源:未闻Code
animal = {'Monkey': monkey_obj, 'Tiger': tiger_obj, 'Panda': panda_obj} |
import weakref class Panda: def __init__(self, name): self.name = name def walk(self): print('我是一只熊猫,正在走路') class Tiger: pass class Monkey: pass panda = Panda('xyz') tiger = Tiger() Monkey = Monkey() weak_dict = weakref.WeakValueDictionary() weak_dict['Panda'] = panda weak_dict['Tiger'] = tiger weak_dict['Monkey'] = moneky |
2020-2-06 13:34
2020-2-04 13:44
2020-2-04 13:18
2020-1-23 09:34
2020-1-23 09:26
2020-1-21 10:12