dog = {'dog': 'A'}
cat = {'cat': 'B'}
pig = {'dog': 'C'}
pets = [dog, cat ,pig]
for pet in pets:
for p, name in pet.items():
print(p + ": " + name)
想用解析打出来,可是总提示错误。正确的打开方式是啥样?
dog = {'dog': 'A'}
cat = {'cat': 'B'}
pig = {'dog': 'C'}
pets = [dog, cat ,pig]
for key, name in [pet.items() for pet in pets]:
print(key + ": " + name)
孤独的小猪
产品经理不是经理
相关分类