简体   繁体   中英

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. And also print the position and maximum value from the data, as for example here is 0.9478542804718018, at position 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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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