如何在列表中打印每个字典的名称?

时间:2016-06-20 16:37:22

标签: python dictionary

我有这段代码:

charlie = {"animal_kind":"german shepherd","owner's_name":"cory", } 
lucy = {"animal_kind":"cat", "owner's_name":"oliver"}
george = {"animal_kind":"ferret", "owner's_name":"stephy"}

pets = [charlie, lucy, george]

我想遍历每个字典并打印字典的名称(而不是字典中的键或值)。 有没有办法做到这一点?

0 个答案:

没有答案