2013-07-16 82 views

回答

3

一個簡單的呼叫到tuple()在這裏就足夠了。

>>> testList = [[1, 2], [1, 3]] 
>>> [tuple(elem) for elem in testList] 
[(1, 2), (1, 3)] 

或者,如果你正在尋找與map做到這一點,那麼,做

>>> map(tuple, testList) 
[(1, 2), (1, 3)]