这个里面怎么统计“吸烟”的个数

新手上路,请多包涵
result ={'person_info':[{'attributes': {'smoke': {'score': 0.9999989867210388, 'name': '吸烟'}}}, {'attributes': {'smoke': {'score': 0.9933449029922485, 'name': '未吸烟'}}}, {'attributes': {'smoke': {'score': 0.9619882702827454, 'name': '未吸烟'}}}]}
阅读 1.8k
1 个回答
result ={'person_info':[{'attributes': {'smoke': {'score': 0.9999989867210388, 'name': '吸烟'}}}, {'attributes': {'smoke': {'score': 0.9933449029922485, 'name': '未吸烟'}}}, {'attributes': {'smoke': {'score': 0.9619882702827454, 'name': '未吸烟'}}}]}
smokec=0
clen=len( result['person_info'] )
for i in range(clen):
    if ( result['person_info'][i]['attributes']['smoke']['name'] == '吸烟') :
        smokec+=1
print(smokec)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题