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)
添加回答
举报
0/150
提交
取消