文章分类 -  Python

摘要:with 语句 阅读全文
posted @ 2017-09-13 20:28 Adamanter 阅读(140) 评论(0) 推荐(0)
摘要:类的使用本质是调用类的内置方法 __getitem__, __setitem__,__delitem__,__delattr__ # 内置方法:__slots__ #实现迭代器协议的内置方法:__iter__,__next__ # 实现range类,__next__进行StopIteration处理 阅读全文
posted @ 2017-09-13 20:16 Adamanter 阅读(130) 评论(0) 推荐(0)
摘要:l=[1,2,3,4,"h","h","l",(1,2,3),[1,2,3]] x=0 y=0 z=0 m=0 for i in l: if isinstance(i,str): x+=1 elif isinstance(i,int): y+=1 elif isinstance(i,tuple): z+=1 el... 阅读全文
posted @ 2017-09-13 20:03 Adamanter 阅读(231) 评论(0) 推荐(0)
摘要:包装和授权 举个例子 # 练习一:重写自定制列表的append和insert方法 # 练习二:根据需求自定制列表 练习三:权限与列表 阅读全文
posted @ 2017-09-13 19:58 Adamanter 阅读(262) 评论(0) 推荐(0)
摘要:类的内置方法:__getattr__,__setattr__,__delattr__ python面向对象中的反射:hasattr,getattr,setattr,delattr 基于模块的反射 重写自定制列表的append和insert方法 阅读全文
posted @ 2017-09-13 19:23 Adamanter 阅读(127) 评论(0) 推荐(0)
摘要:类和对象的绑定和解除绑定 @classmethod 装饰器 @staticmethod 装饰器 @property装饰器 @方法名.setter/@方法名.deleter 总结回答 阅读全文
posted @ 2017-09-13 15:17 Adamanter 阅读(292) 评论(0) 推荐(0)
摘要:经典类和新式类的区别: 经典类就是经典就是旧式类,过去了就经典了,呵。 阅读全文
posted @ 2017-09-13 11:47 Adamanter 阅读(155) 评论(0) 推荐(0)
摘要:基本过程: 看一个学生类简单例子 一个系统例子 什么是抽象类以及特点 基于抽象类的接口与归一化设计 面向对象编程的三大特点:封装,继承,多态 类的继承和派生以及组合: 为什么要用继承:解决代码重用问题 类的封装 类的多态 接口函数隐藏访问内部隐藏属性 经典类和新式类 经典类是py2 的深度优先的类 阅读全文
posted @ 2017-09-12 20:31 Adamanter 阅读(211) 评论(0) 推荐(0)
摘要:什么是递归 所以,要写递归函数主要逻辑必需不断调用,而遇到if 条件必须终止 用递归实现二分法 阅读全文
posted @ 2017-09-12 19:39 Adamanter 阅读(142) 评论(0) 推荐(0)
摘要:什么是函数式编程 函数式编程的基本用法 阅读全文
posted @ 2017-09-12 19:28 Adamanter 阅读(255) 评论(0) 推荐(0)
摘要:什么是哈希 什么是不可哈希 阅读全文
posted @ 2017-09-12 19:25 Adamanter 阅读(596) 评论(0) 推荐(0)
摘要:基本练习 阅读全文
posted @ 2017-09-11 20:28 Adamanter 阅读(172) 评论(0) 推荐(0)
摘要:案例 阅读全文
posted @ 2017-09-11 19:05 Adamanter 阅读(196) 评论(0) 推荐(0)
摘要:三元表达式 列表生成式 生成器表达式 阅读全文
posted @ 2017-09-11 18:54 Adamanter 阅读(124) 评论(0) 推荐(0)
摘要:一个简单的协程案例: 阅读全文
posted @ 2017-09-08 20:02 Adamanter 阅读(97) 评论(0) 推荐(0)
摘要:什么是生成器 # 知乎链接:https://www.zhihu.com/question/20829330 生成器与一般函数比较 生成器举例 阅读全文
posted @ 2017-09-08 19:23 Adamanter 阅读(135) 评论(0) 推荐(0)
摘要:存储方式与遍历 可迭代对象与迭代器 阅读全文
posted @ 2017-09-08 19:11 Adamanter 阅读(141) 评论(0) 推荐(0)
摘要:什么是装饰器 无参数装饰器:就是没有参数的装饰器,一般两层包裹 有参装饰器:就是有参数的装饰器,一般三层包裹 如何使用两种:原函数和新装饰器函数 阅读全文
posted @ 2017-09-08 17:09 Adamanter 阅读(105) 评论(0) 推荐(0)
摘要:from urllib import request fw=open("baidu.txt",mode="w",encoding="utf8") with request.urlopen("http://www.baidu.com") as f: data=f.read() print('Status:',f.status,f.reason) for k,v in ... 阅读全文
posted @ 2017-09-08 16:46 Adamanter 阅读(161) 评论(0) 推荐(0)
摘要:读取黑名单,三次计数,写入黑名单 阅读全文
posted @ 2017-09-08 16:45 Adamanter 阅读(130) 评论(0) 推荐(0)