joe*_*els 3 python dictionary tuples python-3.x
可能重复:
将元组转换为dict
如何更改元组列表,例如:
seq = [(1, 2), (3, 4), (5, 6)]
Run Code Online (Sandbox Code Playgroud)
进入字典:
dicta = { 1:2, 2:4, 5:6 }
Run Code Online (Sandbox Code Playgroud)
Mik*_*wis 10
>>> seq = [(1, 2), (3, 4), (5, 6)]
>>> dict(seq)
{1: 2, 3: 4, 5: 6}
Run Code Online (Sandbox Code Playgroud)
不是python很好:)
如Python Docs中所定义:
The dict() constructor builds dictionaries directly from lists of key-value pairs stored as tuples.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
993 次 |
| 最近记录: |