Python中文
首页
教程
问答
标签
搜索
登录
注册
带词典的列表
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>因此,我正在处理一个由字典及其相应值组成的列表。所以我的问题是,我如何才能使一个变量称为最大值的关键库存数字。可以选择最大值的if语句。我已经试过了:</p> <p>最大值=0 对于牵引车的数量:</p> <pre><code>if "inventory_number" in cars: if int(cars['inventory_number']) >= int(max_value): max_value = int(cars['inventory_number']) towed_cars= [{"color":"RED", "inventory_number":"2870803", "make":"GMC", "plate":"AX21690", "state":"IL", "style":"LL", "tow_date":"2019-02-16T00:00:00.000", "tow_facility_phone":"(773) 568-8495", "towed_to_address":"10300 S. Doty"} , {"color":"SIL", "inventory_number":"2870715", "make":"CHEV", "plate":"AV21919", "state":"IL", "style":"4D", "tow_date":"2019-02-16T00:00:00.000", "tow_facility_phone":"(773) 568-8495", "towed_to_address":"10300 S. Doty"}] </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>也可以使用<code>generator comprehension</code></p> <pre><code>max(int(d.get('inventory_number', 0)) for d in towed_cars) 2870803 </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python猜字gam
10 回答
Python猜字游戏
1 回答
Python猜字游戏?
10 回答
Python猜字游戏不会在玩家猜测所有字母时结束
5 回答
Python猜字游戏在有重复字符的单词上失败
5 回答
Python猜想
4 回答
Python猜数字游戏,而循环没有响应
9 回答
python猜测gam的代码反馈
9 回答
python猜测gam的变量问题
1 回答
python猜测具体路径?
9 回答
Python猜测我的号码(反向号码猜测)UnboundLocalE
3 回答
python猜测该数字在猜测过度后再试一次
6 回答
Python猜猜单词游戏bug
4 回答
Python猜猜游戏如何再现
9 回答
Python猜猜游戏服务器
10 回答
Python猜猜谁的游戏我没有得到我预期的输出
5 回答
Python猜谜游戏
6 回答
Python猜谜游戏,值错误:randrange()的空范围
7 回答
Python猜谜游戏,带尝试选项
2 回答
Python猜谜游戏,我的赢的条件打印赢和输
1 回答