我正在寻找最好的方法来转换一个2D列表到csv文件包含坐标(xyz)为每个点。
2D列表的格式如下:
['586.732'], ['626.012'], ['496.778']
['597.422'], ['536.778'], ['586.056']
['597.422'], ['536.778'], ['586.056']使用:
with open("output.csv", "w") as csvfile:
writer = csv.writer(csvfile)
writer.writerows([x, y, z])将返回一个转置的对象列表,该列表无法轻松绘制。
如果有人能提出解决这个问题的方法,我会很高兴的。
发布于 2017-11-08 22:20:08
使用zip()可以做你想做的事情。
with open("output.csv", "w") as csvfile:
writer = csv.writer(csvfile)
writer.writerows( zip(x, y, z) )csv将如下所示
x1, y1, z1
x2, y2, z2
x3, y3, z3
...https://stackoverflow.com/questions/47181844
复制相似问题