小编ank*_*nkh的帖子

从数字字典中获取最高值作为字符串

production = {
        'item1': '500',
        'item2': '10000',
    }
Run Code Online (Sandbox Code Playgroud)

我试图从该 dict 中获得最高值,即 10000。但是,我得到 500 作为max(production.values()).

我相信它是这样的,因为它从 string 中获得最高值,而不是 int (采用其代码点的字典顺序)。

有人可以帮我解决一个问题。谢谢!

python dictionary max

-1
推荐指数
2
解决办法
179
查看次数

标签 统计

dictionary ×1

max ×1

python ×1