1. 程式人生 > >Python3.6全棧開發實例[018]

Python3.6全棧開發實例[018]

山東 python3 python3.6 pytho none 獲取 劃分 rst fir

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]