LoginSignup
0
0

More than 5 years have passed since last update.

Python > update()でdictionaryの値を差し替える

Last updated at Posted at 2017-03-02

@ 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.

本のコードを参考にサンプルを作ってみた。

equipment = { 'item1': 'double edged sword', 'item2': 'Korejanai Robo'}
print(equipment)
second = {'item2': 'Delta Flyer'}
equipment.update(second)
print(equipment)
結果
{'item2': 'Korejanai Robo', 'item1': 'double edged sword'}
{'item2': 'Delta Flyer', 'item1': 'double edged sword'}

Korejanai Robo
Delta Flyer

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0