一、目标
学习Python的偏函数的用法
二、试验平台
windows7 , python3.7
三、直接上代码
将某个数值转换成二进制。
print(int("11111111", base=2))
def int2(xCS, base=2):
return int(xCS, base)
print(int2("1111"))
# #自定义偏函数
import functools
xInt2 = functools.partial(int, base=2)
print(xInt2("1111"))
'''
输出结果:
255
15
15
'''