
python
python积累
森三木
别怀疑其实就是我!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python闭包与装饰器--下篇
python闭包与装饰器__call__基于类实现的装饰器类装饰器带参数前提:装饰器函数从另一个角度去看其实是一个接口约束,它必须接受一个callable对象作为参数,然后返回一个callable对象。Python中一般callable对象都是函数,但也有例外。只要某个对象重载了__call__()方法,那么这个对象就是callable的callclass Hello(): def __call__(self): print("call me!")if __name原创 2020-05-11 20:45:08 · 204 阅读 · 0 评论 -
python闭包与装饰器--中篇
python闭包与装饰器最简单装饰器被修饰的函数带参数装饰器带参数类装饰器内置装饰器最简单装饰器被修饰的函数带参数装饰器带参数类装饰器内置装饰器原创 2020-05-09 21:06:39 · 338 阅读 · 0 评论 -
python闭包与装饰器--上篇
python闭包与装饰器函数有三种形式闭包装饰器函数有三种形式1.定义形式2.对象形式(函数变量)3.调用形式def outer(): str1 = "我是outer函数str1" print(str1) def inner(): str1 = "我是inner函数str1" print(str1) return innerf=outer()f()#结果:#我是outer函数str1#我是inner函数str1函数嵌原创 2020-05-08 22:56:58 · 380 阅读 · 0 评论 -
5分钟教会你python的random模块
python-random取随机浮点数取整数多选一多选任意洗牌取随机浮点数print(random.random()) # 随机产生一个0-1之间的小数 0 <= n < 1.0print(random.uniform(1, 3))# 随机产生两个数之间的浮点数random.uniform(start,stop)取整数print(random.randint(1, 3)...原创 2020-05-07 23:20:39 · 190 阅读 · 0 评论