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)