生产可以排序
我有一段代码,这是一种被称为一个循环在字典中的功能列表,它如下:生产可以排序
hope = [] seconds = []
hope.append(self.date)
for those in hope:
date = those
pattern = '%m/%d/%Y'
epoch = int(time.mktime(time.strptime(date, pattern)))
seconds.append(epoch)
print seconds
我得到的结果一样
[1505084400] [1500850800]
[1509926400]
[1496617200]
[1492383600]
[1488758400]
[1499036400]
[1511136000]
[1511136000]
…
但我想几秒钟的结果是这样的:
[1505084400,1500850800,1509926400,1496617200,1492383600,1488758400,1499036400,1511136000,1511136000.....]
这样的排序和分类功能将进行这项工作。
回答:
就拿print语句出来的for循环和保持名单的状态:
class someclass(object): def __init__(self):
self.hope = []
self.seconds = []
def appendtoseconds(self):
self.hope.append(self.date)
for those in self.hope:
date = those
pattern = '%m/%d/%Y'
epoch = int(time.mktime(time.strptime(date, pattern)))
self.seconds.append(epoch)
print self.seconds
以上是 生产可以排序 的全部内容, 来源链接: utcz.com/qa/264307.html