好吧,我对python很陌生,希望你能帮我解决这个问题。你知道吗
我有两张单子,彼此对应。现在我想用同样的方法对它们进行分类。你知道吗
我在黑板上找到了解决办法: Is it possible to sort two lists(which reference each other) in the exact same way?
我现在的问题是,我的一个列表是带有日期的字符串。我想按时间顺序排序,但我不知道如何使用关键参数。 以下是我的代码:
daten = ["03. Aug 2012", "30. Jul 2012", "25. Jul 2012"]
werte = [10, 35, 22]
daten, werte = (list(t) for t in zip(*sorted(zip(daten, werte), key=lambda x: datetime.datetime.strptime(x[1], "%d. %b %Y"))))
现在我得到一个TypeError:必须是string,而不是int
您想要
x[0]
而不是x[1]
:相关问题 更多 >
编程相关推荐