小编Dar*_*ama的帖子

如何按日期时间键对python词典进行排序?

我有如下字典:

dt = {'2016-12-15 18:12:17': 1, '2016-12-15 17:40:39': 1, '2016-12-15 15:53:42': 1, '2016-12-15 15:51:41': 1, '2016-12-15 15:49:55': 1, '2016-12-15 15:49:54': 1, '2016-12-15 15:48:05': 1, '2016-12-15 15:27:38': 1, '2016-12-15 09:05:03': 1, '2016-12-15 08:43:45': 1, '2016-12-15 07:29:15': 1, '2016-12-15 05:56:58': 1, '2016-12-14 14:33:31': 1, '2016-12-14 14:33:30': 1, '2016-12-14 14:33:29': 1, '2016-12-14 14:33:28': 1, '2016-12-14 13:24:55': 1, '2016-12-14 13:15:51': 1, '2016-12-14 13:05:38': 1, '2016-12-14 12:58:47': 1}
Run Code Online (Sandbox Code Playgroud)

我想按日期时间键对字典进行排序。

我试过了 :

dt = ordereddict.OrderedDict()
Run Code Online (Sandbox Code Playgroud)

但是它不起作用,请帮忙。

python dictionary

1
推荐指数
1
解决办法
3112
查看次数

标签 统计

dictionary ×1

python ×1