Python——找出内层字典中所用到的全部键,并以集合的形式返回
程序员文章站
2022-04-29 19:01:24
...
'''
3. 编写一个叫做db_headings的函数,要求能够找出内层字典中所用到的全部键,并以集合的形式返回。
以给出的字典为例,该函数应该返回集合{'author', 'forename', 'born', 'surname', 'notes', 'died'}。
{
'jgoodall':{'surname':'goodall',
'forename':'Jane',
'born':1934,
'died':None,
'notes':'primate researcher',
'author':['In the Shadow of Man','The Chimpanzees of Gombe']},
'rfranklin':{'surname':'Franklin',
'forename':'Rosalind',
'born':1920,
'died':1957,
'notes':'contributed to discovery of DNA'},
'rcarson':{'surname':'Carson',
'forename':'rachel',
'born':1907,
'died':1964,
'notes':'raised awareness of effects of DDT',
'author':['Silent Sporing']}
}
''''''
太晚了明天写……