LoginSignup
0
2

More than 5 years have passed since last update.

Python > two value sequenceをdictionaryに変換

Last updated at Posted at 2017-03-02

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 1515 / 12833)

You can use the dict() function to convert two-value sequences into a dictionary.

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

lol = [ [ 'pi', '3.1415'], ['napier', '2.71828'], ['avogadro', '6.022 x 10^23'] ]
print(lol)

mydict = dict(lol)
print(mydict['avogadro'])
結果
[['pi', '3.1415'], ['napier', '2.71828'], ['avogadro', '6.022 x 10^23']]
6.022 x 10^23

ファイル変換とかで使うだろうか。

0
2
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
2