03 2019 档案

序列化与反序列化
摘要:#序列化:把变量从内存变成可存储或者传输的过程#反序列化:把变量内容从序列化对象重新读取到内存里 阅读全文

posted @ 2019-03-06 11:56 er先森 阅读(154) 评论(0) 推荐(0) 编辑

Python用@property使类方法像属性一样访问
摘要:class Screen(object): @property #读取with的值getter方法 def width(self): return self._width @width.setter #设置with的值setter方法 def width(self,value): self._width = value ... 阅读全文

posted @ 2019-03-05 10:26 er先森 阅读(443) 评论(0) 推荐(0) 编辑

笔记(assert 断言)
摘要:并发:在同一个时间段交替执行多个任务并行:在同一个时间点同时执行多个任务串行:同时执行的多个任务按顺序执行(换句话说就是一个任务执行完后才能执行下一个任务) #mysql limit用法: select * from table limit m,n;m表示第m+1条数据起(因为索引是从零开始的)n表 阅读全文

posted @ 2019-03-05 10:19 er先森 阅读(433) 评论(0) 推荐(0) 编辑

Python使用__slots__限制实例属性
摘要:#定义一个类Student class Student(object): __slots__ = ('name','age') #用元组(tuple)的形式绑定属性名称 s = Student() s.name = 'xh' print s.name #xh #s.score = 88 #因为 __slots__中没有score属性,所以报错 #print s.score #A... 阅读全文

posted @ 2019-03-05 09:43 er先森 阅读(224) 评论(0) 推荐(0) 编辑

分别给Python类和实例增加属性和方法
摘要:#定义一个类Student class Student(object): pass #给类增加一个属性name Student.name = 'xm' print Student.name # xm #给类增加一个方法set_age def set_age(self,age): self.age = age Student.set_age = set_age s = Stu... 阅读全文

posted @ 2019-03-05 09:27 er先森 阅读(3671) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示