2016-11-10 155 views
-2

我想使用Python将列表的列表转换为元组列表。但是我想在不重复嵌套列表的情况下这样做,因为它会增加脚本的执行时间。有什么方法可以锻炼我吗?Python将列表的列表转换为元组列表

由于提前

+2

您可以避免使用[列表解析]写一个显式循环(https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions)或['map'函数](https://docs.python.org/2/library/functions.html#map),但它仍然会遍历所有数据。 – khelwood

回答

0
converted_list = [tuple(i) for i in nested_list]