@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1593 / 12833)
You can use the update() function to copy the keys and values of one dictionary into another.
Ich habe ein Beispiel gemacht, indem ich mich auf den Code im Buch bezogen habe.
http://ideone.com/uMxSqe
equipment = { 'item1': 'double edged sword', 'item2': 'Korejanai Robo'}
print(equipment)
second = {'item2': 'Delta Flyer'}
equipment.update(second)
print(equipment)
Ergebnis
{'item2': 'Korejanai Robo', 'item1': 'double edged sword'}
{'item2': 'Delta Flyer', 'item1': 'double edged sword'}
Recommended Posts