2016年10月28日

摘要: 空类 Michael 创建实例,绑定name属性 绑定前,先定义方法 set_age 引入 MethodType 给实例s绑定set_age方法 调用方法 看结果 当然,再创建个新实例,是没有这个绑定关系的。 想给所有实例一次绑定,就给类绑定方法。 阅读全文
posted @ 2016-10-28 12:23 chinxfin 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Traceback (most recent call last): File "<stdin>", line 1, in <module>AttributeError: 'Student' object has no attribute 'score' 由于'score'没有被放到__slots_ 阅读全文
posted @ 2016-10-28 10:46 chinxfin 阅读(83) 评论(0) 推荐(0) 编辑

2016年10月27日

摘要: __XXX 不能访问 非要访问的话_类名__XXX 阅读全文
posted @ 2016-10-27 15:35 chinxfin 阅读(123) 评论(0) 推荐(0) 编辑

2016年10月26日

摘要: 旧的版本中试验新版本的一些特性 from __future__ import division from __future__ import unicode_literals 阅读全文
posted @ 2016-10-26 13:36 chinxfin 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 图像处理pil:http://effbot.org/downloads/#pil 搜索路径增加 阅读全文
posted @ 2016-10-26 13:28 chinxfin 阅读(80) 评论(0) 推荐(0) 编辑

2016年10月25日

摘要: 固定一个参数 结果:10 “当函数的参数个数太多,需要简化时,使用functools.partial可以创建一个新的函数,这个新函数可以固定住原函数的部分参数,从而在调用时更简单。” 阅读全文
posted @ 2016-10-25 17:35 chinxfin 阅读(85) 评论(0) 推荐(0) 编辑
摘要: decorator就是一个返回函数的高阶函数 log函数,参数text decorator 参数为func函数 wrapper函数 打印text和func函数名 返回func函数 返回wrapper函数 返回decorator函数 埋日志 执行函数 结果:execute now(): now 阅读全文
posted @ 2016-10-25 15:32 chinxfin 阅读(112) 评论(0) 推荐(0) 编辑
摘要: % 求模运算,相当于mod % s%d 阅读全文
posted @ 2016-10-25 13:17 chinxfin 阅读(68) 评论(0) 推荐(0) 编辑

2016年10月24日

摘要: #过程:1.88,77,66 2.88*10+77=957 3.957*10+66=9636 阅读全文
posted @ 2016-10-24 22:20 chinxfin 阅读(90) 评论(0) 推荐(0) 编辑
摘要: #切片 L = ['A','B','C','D','E'] L[0:3] #如果第一个索引是0,还可以省略 L[:3] L[-2:] L[-2:-1] L[-10:] L[:10:2] L[::5] L[:] #list、tuple、字符串都可以切片 #range() #5开始,10以内的 range(5, 10) #0开始,10以内的,步长3 range(0,... 阅读全文
posted @ 2016-10-24 13:25 chinxfin 阅读(96) 评论(0) 推荐(0) 编辑

导航