python:优雅和代码保存方式转换列表

Gia*_*ear 0 python optimization performance coding-style

首先抱歉这个简单的问题.我有一个清单(只是一个例子)

points = [[663963.7405329756, 6178165.692240637],
 [664101.4213951868, 6177971.251818423],
 [664099.7474887948, 6177963.323432223],
 [664041.432877932, 6177903.295650704],
 [664031.8017317944, 6177895.797176996],
 [663963.7405329756, 6178165.692240637]]
Run Code Online (Sandbox Code Playgroud)

我需要将其转换为以下形式

points = [(663963.7405329756, 6178165.692240637),
 (664101.4213951868, 6177971.251818423),
 (664099.7474887948, 6177963.323432223),
 (664041.432877932, 6177903.295650704),
 (664031.8017317944, 6177895.797176996),
 (663963.7405329756, 6178165.692240637)]
Run Code Online (Sandbox Code Playgroud)

为了Polygon使用shapely模块创建一个对象.我写了几个循环,但真的不优雅和耗时.你知道将第一个列表转换成第二个列表的最佳方法吗?

谢谢

Lev*_*sky 5

converted = map(tuple, points) # Python 2
converted = list(map(tuple, points)) # or BlackBear's answer for Python 3
converted = [tuple(x) for x in points] # another variation of the same
Run Code Online (Sandbox Code Playgroud)