简体   繁体   中英

Returning specific Dictionary Values Python

How do I return dictionary values with .values() ? 'dict_values' object is not subscriptable , so I cannot use dict.values()[0] to retrieve the first array [2.96762712e+03, 8.38541299e-01, 1.32466671e-02]

dict_values([array([2.96762712e+03, 8.38541299e-01, 1.32466671e-02]), array([2.96762712e+03, 8.38541299e-01, 1.32466671e-02]), array([2.96762712e+03, 8.38541299e-01, 1.32466671e-02]), array([2.96762712e+03, 8.38541299e-01, 1.32466671e-02])])

在索引之前转换为列表:

list(dict.values())[0]

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