python-3.8 - 在python3中计算dict中的键
问题描述
我是 python 新手,我想获取“actionType”键的总数,如果计数大于 2,我需要使用 actiontype、state、severname 创建新的 json。我怎样才能做到这一点。
"actions": [
{
"id": "xxx",
"createdAt": "2012xxx",
"actionType": "start",
"state": "failed",
"serverName": "test1",
}
{
"id": "xxx",
"createdAt": "2012xxx",
"actionType": "stop",
"state": "failed",
"serverName": "test2",
}
{
"id": "xxx",
"createdAt": "2012xxx",
"actionType": "start",
"state": "failed",
"serverName": "test3",
}
{
"id": "xxx",
"executor": "xxxx",
"createdAt": "2012xxx",
"actionType": "start",
"state": "failed",
"serverName": "test4",
}
]
解决方案
推荐阅读
- c# - 将复杂的数据结构从 C# 传递到本机 dll
- install4j - 如何添加在使用 install4j 安装应用程序后调用的自定义选项?
- docbook - 从 asciidoc 转换时,有没有办法在 docbook 中不忽略自定义属性?
- tensorflow - Keras 的模型评估期望的训练集维度而不是测试集维度
- python-3.x - 如何使用 urllib 和 Python3 访问 JSON 元素
- angular - ThreeJS / Angular - “场景未定义”
- angular - NativeScript Angular ngClass 不起作用
- reactjs - React-Leaflet 在开发环境中渲染本地图块
- c++ - 如何获取指针类型而不是 UNKNOWN
- akka-http - 如何为从 ByteString 创建的 HttpRequest/HttpEntity 设置块大小