您将要遍历(key, value)对,将匹配累积到列表,然后返回该列表.
(key, value)
一个列表解析得到很好地完成工作:
def fruit(food_type): return [k for k, v in food_type.items() if v == 'fruit']