码迷,mamicode.com
首页 > 编程语言 > 详细

Python3.6全栈开发实例[018]

时间:2018-08-11 19:36:25      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:location   山东   位置   style   pre   one   获取   python3   pytho   

18.车牌区域划分, 现给出以下车牌.根据车牌的信息, 分析出各省的车牌持有量.(升级题)

result = {}
for car in cars:
    location = locals[car[0]]
    result[location] = result.get(location,0)+1
print(result)
result = {}
for car in cars: # car 车牌子
    first_name = car[0] # 山东
    location = locals[first_name]
    # 进行统计
    if result.get(location) == None:  # 如果获取当前位置. 找不到对应的车辆的数量
        result[location] = 1  # 第一辆车
    else:
        result[location] = result[location] + 1  # 第n量
print(result)

 

Python3.6全栈开发实例[018]

标签:location   山东   位置   style   pre   one   获取   python3   pytho   

原文地址:https://www.cnblogs.com/apollo1616/p/9460714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!