1 def str2int(s): 2 def fn(x,y): 3 return x+y 4 def char2num(s): 5 return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s] 6 return reduce(fn,map(char2num,s)) 7 8 print(str2int('2468')) 9
2023-10-11 19:37:22
1 def str2int(s): 2 def fn(x,y): 3 return x+y 4 def char2num(s): 5 return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s] 6 return reduce(fn,map(char2num,s)) 7 8 print(str2int('2468')) 9
下一篇:二维码登录原理及生成与解析