我有一本字典,看起来像这样
{
'Host-A': {'requests':
{'GET /index.php/dashboard HTTP/1.0': {'code': '200', 'hit_count': 3},
'GET /index.php/cronjob HTTP/1.0': {'code': '200', 'hit_count': 4},
'GET /index.php/setup HTTP/1.0': {'code': '200', 'hit_count': 2}},
'total_hit_count': 9},
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,'Host-A'该值是一个字典,包含收到的请求和每个页面上的点击次数。问题是如何按'requests'降序排序。这样我就可以得到最重要的请求。
正确解决方案输出的示例如下:
{
'Host-A': {'requests':
{'GET /index.php/cronjob HTTP/1.0': {'code': '200', 'hit_count': 4},
'GET /index.php/dashboard HTTP/1.0': {'code': '200', 'hit_count': 3},
'GET /index.php/setup HTTP/1.0': {'code': '200', 'hit_count': 2}},
'total_hit_count': 9},
}
Run Code Online (Sandbox Code Playgroud)
我感谢您的帮助