どうも、ちょげ(@chogetarou)です。
タプルのリスト(List)を辞書に変換する方法を紹介します。
方法

タプルのリスト(List)を辞書に変換するには、dict()を使います。
まず、dict()を呼び出します。
そして、dict()の引数にタプルのリストを指定します。
result = dict(my_tuple)
上記のdict()は、引数に指定したタプルのリストを辞書に変換した結果を返します。
使用例
my_tuple = [('one', 1), ('two', 2), ('three', 3)]
result = dict(my_tuple)
print(result)
出力:
{'one': 1, 'two': 2, 'three': 3}
コメント