@ 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.
I made a sample based on the code of the book.
http://ideone.com/HMftGs
lol = [ [ 'pi', '3.1415'], ['napier', '2.71828'], ['avogadro', '6.022 x 10^23'] ]
print(lol)
mydict = dict(lol)
print(mydict['avogadro'])
result
[['pi', '3.1415'], ['napier', '2.71828'], ['avogadro', '6.022 x 10^23']]
6.022 x 10^23
Will it be used for file conversion?
Recommended Posts