简体   繁体   English

如何从dict中的值列表中获取每个值

[英]how to get each values from a list of values in dict

I want this [9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803] data from the printed output listed below.我想要这个[9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803]列于[9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803]输出[9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803] And also print the position and maximum value from the data, as for example here is 0.9478542804718018, at position 2.并从数据中打印位置和最大值,例如这里是 0.9478542804718018,在位置 2。

{'fields': ['prediction', 'prediction_classes', 'probability'], 'values': [[[9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803], 2, [9.623322512197774e-06, 0.0003608197148423642, 0.9478542804718018, 5.152213998371735e-05, 0.05172383785247803]]]}

To get the list of values获取值列表

v = d['values'][0][0]

To get the max value in the list获取列表中的最大值

max(v)

To get the index of the max value获取最大值的索引

v.index(max(v))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM