随笔分类 -  python语言

python语言
摘要:生成器是一种特殊的迭代器。 用生成器实现斐波那契数列: from collections import Iterator, Iterable def create_nums(num): a, b = 1, 1 cnt = 0 while cnt < num: yield a a, b = b, a 阅读全文
posted @ 2020-03-31 10:45 olivertian 阅读(127) 评论(0) 推荐(0)
摘要:from collections import Iterable, Iterator class ClassIterator: """迭代器必须实现__iter__和__next__方法,故迭代器一定是可迭代对象""" def __init__(self, obj): self.obj = obj 阅读全文
posted @ 2020-03-31 00:04 olivertian 阅读(255) 评论(0) 推荐(0)
摘要:2020/1/31 - 2020/2/8 1、元类: 2、all()方法:https://www.runoob.com/python/python-func-all.html 阅读全文
posted @ 2020-01-31 15:26 olivertian 阅读(97) 评论(0) 推荐(0)
摘要:两篇很好的文章: https://blog.51cto.com/kaifly/2115249 https://stackoverflow.com/questions/100003/what-are-metaclasses-in-python(看最高赞,即第二个回答) 一点想法: 1、type是typ 阅读全文
posted @ 2020-01-27 16:55 olivertian 阅读(187) 评论(0) 推荐(0)
摘要:装饰器本质是一个函数,装饰器装饰一个函数,其实就是返回另一个函数,强调装饰器本质是函数以及返回的是函数,这个比较重要,因为装饰器语法看起来挺唬人的,其实也就是把对函数的操作绕了两三下,没啥高大上的内容 1、多层装饰器: def makeBold(fun): print("***** 1 ****** 阅读全文
posted @ 2020-01-19 23:11 olivertian 阅读(284) 评论(0) 推荐(0)
摘要:Unicode是个规范,可以理解为一个索引表,世界上所有字符基本上在这个索引表中都能找到唯一一个数码与之对应,就像ASCII码表一样,也是一个规范,也可以看成是一个索引表,所有的英文字符都可以在这个索引表中找到唯一一个数码与之对应。 在ASCII码表中,'\x61'对应的是字母'a',\x表示告诉计 阅读全文
posted @ 2019-10-08 11:03 olivertian 阅读(443) 评论(0) 推荐(0)
摘要:“当看到一只鸟走起来像鸭子、游泳起来像鸭子、叫起来也像鸭子,那么这只鸟就能够被称为鸭子” python的鸭子类型的设计让python的诸多对象的分类和应用更加灵活,需要注意类型和对象的区别(python的类也是对象),类型概念包含的范围更广,比如可迭代类型就包括list,tuple等类,这里list 阅读全文
posted @ 2019-10-06 13:35 olivertian 阅读(735) 评论(0) 推荐(0)
摘要:关于python异步编程的演进过程,两篇文章阐述得妥妥当当,明明白白。 中文资料:https://mp.weixin.qq.com/s?__biz=MzIxMjY5NTE0MA==&mid=2247483720&idx=1&sn=f016c06ddd17765fd50b705fed64429c 英文 阅读全文
posted @ 2019-09-02 03:01 olivertian 阅读(3259) 评论(0) 推荐(2)
摘要:转自:https://www.cnblogs.com/coder2012/p/4990834.html 阅读全文
posted @ 2019-08-21 15:21 olivertian 阅读(321) 评论(0) 推荐(0)
摘要:转自:https://www.cnblogs.com/huxi/archive/2010/06/26/1765808.html 阅读全文
posted @ 2019-08-03 16:50 olivertian 阅读(131) 评论(0) 推荐(0)
摘要:首先了解这两者是什么。 以下说明参考自python官网 Lock:Lock被称为①原始锁,原始锁是一个②在锁定时不属于特定线程的同步基元组件,它是能用的最低级的同步基元组件。原始锁处于 "锁定" 或者 "非锁定" 两种状态之一。它被创建时为非锁定状态。它有两个基本方法, acquire() 和 re 阅读全文
posted @ 2019-08-03 15:42 olivertian 阅读(4452) 评论(2) 推荐(2)
摘要:转自:https://stackoverflow.com/questions/33153404/python-typeerror-init-got-multiple-values-for-argument-master super().__init__(self, **kwargs) # super 阅读全文
posted @ 2019-08-01 03:18 olivertian 阅读(5755) 评论(0) 推荐(0)
摘要:转自Stack Overflow:https://stackoverflow.com/questions/42800250/difference-between-open-and-io-bytesio-in-binary-streams 还有一篇python官网的相关知识,需要一起学习下:https 阅读全文
posted @ 2019-07-27 20:45 olivertian 阅读(479) 评论(0) 推荐(0)
摘要:原文:https://www.cnblogs.com/huchong/p/8244279.html 另一篇关于.pyc文件是什么? 原文: http://blog.sina.com.cn//s/blog_17bce02530102ya3k.html 一:什么是pyc文件? pyc文件就是 py程序编 阅读全文
posted @ 2019-07-10 22:26 olivertian 阅读(216) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/xie_0723/article/details/51958243 阅读全文
posted @ 2019-06-16 09:51 olivertian 阅读(623) 评论(0) 推荐(0)
摘要:virtualenv参考:https://www.jb51.net/article/114933.htm virtualenvwrapper参考:https://www.jianshu.com/p/7ed2dfa86e90 virtualenvwrapper官网:https://virtualenv 阅读全文
posted @ 2019-06-14 01:32 olivertian 阅读(255) 评论(0) 推荐(0)
摘要:原文:https://www.jb51.net/article/156927.htm 阅读全文
posted @ 2019-06-13 17:37 olivertian 阅读(506) 评论(0) 推荐(0)
摘要:转1:https://www.cnblogs.com/aademeng/articles/7262520.html 转2:https://blog.csdn.net/u010377372/article/details/70256043 转3:https://blog.csdn.net/u01281 阅读全文
posted @ 2019-06-08 20:27 olivertian 阅读(637) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/xc_zhou/article/details/80810111 python __enter__ 与 __exit__的作用,以及与 with 语句的关系 阅读全文
posted @ 2019-05-21 21:40 olivertian 阅读(190) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/-900401/p/4015048.html 很受益的一篇文章,特别是后面对四种模型的解析。 理解阻塞和非阻塞,同步异步,有一个核心点要搞清楚就是用户发起内核调用的时候,内核处理分两个阶段:一是准备数据,二是把数据拷贝到用户态内存。 可以近似把内核处理 阅读全文
posted @ 2019-05-17 12:55 olivertian 阅读(186) 评论(0) 推荐(0)