搜索一個值搜索一個值,並得到母公司的字典名稱(鍵):嵌套字典蟒蛇
Dictionary = {dict1:{
'part1': {
'.wbxml': 'application/vnd.wap.wbxml',
'.rl': 'application/resource-lists+xml',
},
'part2':
{'.wsdl': 'application/wsdl+xml',
'.rs': 'application/rls-services+xml',
'.xop': 'application/xop+xml',
'.svg': 'image/svg+xml',
},
'part3':{...}, ...
dict2:{
'part1': { '.dotx': 'application/vnd.openxmlformats-..'
'.zaz': 'application/vnd.zzazz.deck+xml',
'.xer': 'application/patch-ops-error+xml',}
},
'part2':{...},
'part3':{...},...
},...
在上面字典我需要尋找像值:"image/svg+xml"
。其中,字典中沒有重複的值。如何搜索"image/svg+xml"
?以便它應該返回字典{ dict1:"part2" }
中的父鍵。
請注意:解決方案應該工作未修改爲都的Python 2.7和Python 3.3。
請不要使用矛盾的標籤......選擇一種或另一種。 –
@ aj8uppal - 這是因爲,我不想在這兩個python版本中得到答案。如果它在Python 2.7中工作,它必須在Python 3.3中工作,反之亦然。因爲我們有兩臺服務器。一個是使用python2.7,另一個是最新的。我們正在編寫一個腳本,它應該在服務器上運行。對於那個很抱歉! –