2011-03-25 78 views

回答

9
>>> seq = [(1, 2), (3, 4), (5, 6)] 
>>> dict(seq) 
{1: 2, 3: 4, 5: 6} 

是不是蟒蛇好:)

正如Python Docs定义:

The dict() constructor builds dictionaries directly from lists of key-value pairs stored as tuples. 
+0

谢谢!是的!!! – joeywheels 2011-03-25 03:56:16