Unten ist die Ausgabe, die nach einem Merge-Prozess erhalten wurde.Wie man einen neuen Schlüssel hinzufügt und einen vorhandenen Wert in einem Lexikon des Wörterbuchs in Python übereinstimmt?
{
u'a '{u'id' [u'VPH65848HI '], u'social_links' [ 'linkedin_link', 'facebook_link'],
u'b '{ u'id '[u'VPH65848HJ'], u'social_links '[' linkedin_link‘, 'facebook_link']
}
My gewünschte Ausgabe ist
{
u'a ': {u'id': [u'v-PH65848HI '], u'social_links': { 'linkedin': [ 'linkedin_link'], 'Facebook: [' facebook_link ']}},
u'b': {u'id ': [u'V-PH65848HJ'], u'social_links ': {' linkedin ': [' linkedin_link '],' facebook: [ 'facebook_link']}}
}
die unten ist der Code:
for k,v in result.items():
if v['social_links']:
for v1 in v['social_links']:
if "facebook" in v1:
result['facebook']=result['social_links'][1]
Ich weiß nicht, wie ich damit fortfahren soll. Freundlich helfen ! Danke im Voraus.
Wäre schön, Ihre Eingabe zu teilen, wie gut ... – Julien
@Julien: Ich denke, die erste Blockquote der Eingang (die Ausgabe von _Some other_ Prozess). –