How to get value from the dict..?

This question already has an answer here:

  • Iterating over dictionaries using 'for' loops 12 answers

  • 将您的代码更改为:

     for data in digit_count:
                contents.append(digit_count[data])
    

    You want to get the values from your dictionary; just use the .values() method.

    vals = digit_count.values()
    

    Instead of this:

    for data in digit_count:
        contents.append(data)
    

    You can use:

    contents = digit_count.values()
    
    链接地址: http://www.djcxy.com/p/30372.html

    上一篇: python keyworded lambda函数

    下一篇: 如何从字典中获得价值..?