1 Star 0 Fork 3

tonyklose1984 / LearningPython

forked from celaraze / learning-python 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
17.偏函数.py 468 Bytes
一键复制 编辑 原始数据 按行查看 历史
# int函数可以把字符串转为整数
import functools
print(int('12345'))
# int提供额外的参数,默认是10,代表10进制,也可以自定义参数值
print(int('12345', base=8))
print(int('12345', base=16))
# partial可以创建一个偏函数
# 就是把某个函数的某些参数给固定住,返回一个新的函数
intTwo = functools.partial(int, base=2)
print(intTwo('10000'))
# 创建偏函数也可以使用函数对象 或者 *args 或者 **kw
Python
1
https://gitee.com/tonyklose1984/LearningPython.git
git@gitee.com:tonyklose1984/LearningPython.git
tonyklose1984
LearningPython
LearningPython
master

搜索帮助