辞書に対して、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
関連記事
pyplot.errorbar を使って設定する。 オプションの詳細は https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.erro …
matplotlib で、グラフのタイトルに上付き文字を入力する方法
数学記号などで、グラフのタイトルに上付きの文字を入力したい場合がある。 その場合は次のように書いて設定できる。 例 import numpy as np from matplotlib import …
matplotlib で、x,y の軸上の数値を表示する方法
ax の xtics と ytics を使って表示する。 詳細は次のドキュメントを参照。 https://matplotlib.org/stable/gallery/lines_bars_and_ma …
matplotlib で折れ線グラフの下部に色をつけて塗りつぶす方法
pyplot の fill_between を使う。 例 from matplotlib import pyplot as plt data_x = [25,26,27] data_y = & …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。