{{cd1> 但我得到了 相反,我想保存我的 有谁能帮我解决这个问题吗?在d=[[1,2,3,4,5,6],[2,3,4,5,6,7]]
timestamp = [0.1, 0.3] # Basically timestamping for each list of d
file = open('test.csv', 'w')
writer = csv.writer(file, delimiter=',',lineterminator='\n')
writer.writerows(zip(d, timestamp))
csv
,如下所示:col1,col2, ...,col7
1,2,3,4,5,6, 0.1
2,3,4,5,6,7, 0.3
另一种稍微不同的方法是:
这将迭代行
^{pr2}$(但基本上与this answer中的想法相同)
您可以将
timestamp
中的每个项目添加到d
中相应的子列表中:你的代码变成:
^{pr2}$在Python3中,您可以使用扩展解包,而不必创建内部列表:
相关问题 更多 >
编程相关推荐