t = int('123445') print(t) t = int('123', 4) print(t) #23 t = int('123', base = 8) print(t) #83 t = int('12', 16) print(t) #18 def int2(x, base = 8): return int(x, base) t = int2('12') print(t) import functools int2 = functools.partial(int, base = 2) #这里固定了int的参数base t = int2('1111') print(t) #15 #上面代码相当于 kw = {'base' : 2} t = int('1000', **kw) print(t) #8 max2 = functools.partial(max, 10) t = max2(1, 3, 5, 6) #实际上会把10作为*args的一部分自动加到左边,也就相当于max(10, 1, 3, 5, 6) print(t) #10