辞書に対して、items() メソッドを使うと、タプルを作成することができる。
例
cities = {'東京':1000,'大阪':700, '広島':100}
for a,b in cities.items():
print('a:'+a+' b:'+str(b))
結果
a:東京 b:1000 a:大阪 b:700 a:広島 b:100
雑記
投稿日:2020年12月3日 更新日:
辞書に対して、items() メソッドを使うと、タプルを作成することができる。
cities = {'東京':1000,'大阪':700, '広島':100}
for a,b in cities.items():
print('a:'+a+' b:'+str(b))
a:東京 b:1000 a:大阪 b:700 a:広島 b:100
執筆者:seyanen
関連記事
matplotlib でグラフ表示ウィンドウの画面上の位置を自由に設定する方法
matplotlib.use(‘TkAgg’) としておき、 get_current_fig_manager().window.wm_geometry(“+20+50”) として、(+20+50)のと …
「linestyle = 」として、線の種類を指定することができる設定の詳細は、次のリンクを参照。 https://matplotlib.org/stable/gallery/lines_bars_a …
matplotlib で、複数のグラフを簡単にプロットする方法
変数を並べて書くと、次のように自動的に順番を理解してグラフを表示してくれる。 例 import numpy as np from matplotlib import pyplot as plt fro …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。