1. dict.get(key,func)(param)
例:
def func1(param):
print(f'func1: {param}')
def func2(param):
print(f'func2: {param}')
action={
1: func1,
2: func2,
3: print,
}
action.get(key,print)(param)
相当于 func(param) 直接调用函数了
2. 自己看
def getHKid():
hk_id=int(random.random()*26+1)
sums=hk_id*8
hk_id=chr(hk_id+64)
for i in range(1,7):
s=round(random.random()*9)
sums=sums+s*(8-i)
hk_id=f'{hk_id}{s}'
return f'{hk_id}{11-(sums%11)}'
.......