2024-09-29 06:34:04 发布
网友
我试图使用python从json数据中提取某些信息。数据如下所示:
{ "properties": { "detectedName": "servername1", "cpuCores": 60, }, ] } }
我需要能够检索csv中的所有数据。但对于started,我需要“detectedName”和“cpuCores”
我试过这个:
data['detectedName']['cpuCores'])
我发现“detectedName”未找到错误
有什么想法吗
要获取detectedName:name = data['properties']['detectedName']
detectedName
name = data['properties']['detectedName']
要获取cpuCores:cores = data['properties']['cpuCores']
cpuCores
cores = data['properties']['cpuCores']
它们必须在不同的行上,并且都在properties键下
properties
您需要这样写:data['properties']['detectedName'] 或数据['properties']['cpuCores']
要获取
detectedName
:name = data['properties']['detectedName']
要获取
cpuCores
:cores = data['properties']['cpuCores']
它们必须在不同的行上,并且都在
properties
键下您需要这样写:data['properties']['detectedName'] 或数据['properties']['cpuCores']
相关问题 更多 >
编程相关推荐