如何使输出的最后一列只包括列表中的每个元素,而不是整个列表



我使用python将一些列表中的数据排列在列中。我遇到了问题,因为最后一列包含了列表中的所有元素,而不是每行的每个元素。

代码:

from datetime import datetime
list = [5275116,5275140,5275164,5275188,5275212,5275236,5275260,5275284,
5275308,5275332,5275356,5275380,5275404,5275428,5275452,5275476,
5275500,5275524,5275548,5275572,5275596,5275620,5275644,5275668,
5275692,5275716,5275740,5275764,5275788,5275812,5275836,5275860,
5275884,5275908,5275932,5275956]
timestamp = [i * 300 for i in list]
for ts in timestamp:
for element in list:
print("{} - Auction Nr. - {}".format(datetime.fromtimestamp(ts), list))

我的输出结果是这样的(只是其中的一部分(:

2020-02-27 08:00:00 - Auction Nr. - [5275116, 5275140, 5275164, 5275188, 5275212, 5275236, 5275260, 5275284, 5275308, 5275332, 5275356, 5275380, 5275404, 5275428, 5275452, 5275476, 5275500, 5275524, 5275548, 5275572, 5275596, 5275620, 5275644, 5275668, 5275692, 5275716, 5275740, 5275764, 5275788, 5275812, 5275836, 5275860, 5275884, 5275908, 5275932, 5275956]
2020-02-27 08:00:00 - Auction Nr. - [5275116, 5275140, 5275164, 5275188, 5275212, 5275236, 5275260, 5275284, 5275308, 5275332, 5275356, 5275380, 5275404, 5275428, 5275452, 5275476, 5275500, 5275524, 5275548, 5275572, 5275596, 5275620, 5275644, 5275668, 5275692, 5275716, 5275740, 5275764, 5275788, 5275812, 5275836, 5275860, 5275884, 5275908, 5275932, 5275956]

我希望每一行都像这样:

2020-02-24 10:00:00 - Auction Nr. - 5275116

谢谢!

反弹:如何将时间转换为UTC?目前是UTC+1

这同时在timestamp和list_上迭代(我添加了下划线,这样你就不会对内置关键字list加阴影(:

from datetime import datetime
list_ = [5275116,5275140,5275164,5275188,5275212,5275236,5275260,5275284,
5275308,5275332,5275356,5275380,5275404,5275428,5275452,5275476,
5275500,5275524,5275548,5275572,5275596,5275620,5275644,5275668,
5275692,5275716,5275740,5275764,5275788,5275812,5275836,5275860,
5275884,5275908,5275932,5275956]
timestamp = [i * 300 for i in list_]
for ts, el in zip(timestamp, list_):
print("{} - Auction Nr. - {}".format(datetime.fromtimestamp(ts), el))

相关内容

  • 没有找到相关文章

最新更新