比如var1
Range Value
1-5 --- 3
6-7 --- 8
8-11 --- 20
...
Var2
Chicago --- 10
New york --- 15
如果数据很大, 变量多, 用if- else 很慢
if var1 >= 1 and var1 <5:
value = 3
elif var >=6 and var1 < 7:
value = 8
....
if var2 = 'chicago':
value = 10
Python 有没有好的函数做这个?
最好能handle所有情况, 而不是每个var都不一样