![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
huangwencai123
这个作者很懒,什么都没留下…
展开
-
python--__str__和__repr__()区别
python–str__和__repr()两者的区别是1、str()返回用户看到的字符串,2、而__repr__()返回程序开发者看到的字符串,也就是说,repr()是为调试服务的。使用时:class Student(object): def __init__(self, name,callback=None, method='GET',meta=None,flags=Non...原创 2019-06-12 14:36:32 · 251 阅读 · 0 评论 -
python--类的单例模式的实现
python–类的单例模式的实现单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在。当你希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场。使用:1、在调度器的初始化__init__()中初始化类,则会是单例了2、使用__new___ 设置。1)new_ 本身用来初始化实例, 如果check 到内存中有初始...原创 2019-06-12 11:48:07 · 314 阅读 · 1 评论 -
python--log的实现
python–log的实现1、日志等级# 日志的五个等级,等级依次递增# 默认是WARNING等级logging.DEBUGlogging.INFOlogging.WARNINGlogging.ERRORlogging.CRITICAL# 设置日志等级logging.basicConfig(level=logging.INFO)# 使用logging.debug('DEBU...原创 2019-06-12 11:39:36 · 4396 阅读 · 1 评论 -
python--装饰器deorator--高级
python–装饰器deorator-- 高级"""如何优化你的装饰器 1、wrapt是一个功能非常完善的包,用于实现各种你想到或者你没想到的装饰器。 2、使用wrapt实现的装饰器你不需要担心之前inspect中遇到的所有问题,因为它都帮你处理了,甚至inspect.getsource(func)也准确无误""""""1、无参数 注要pip"""import w...原创 2019-06-12 11:35:35 · 191 阅读 · 0 评论 -
python--装饰器deorator--1
python–装饰器deorator装饰器 :装饰器的作用就是为已经存在的函数或对象添加额外的功能1、装饰器本质上是一个Python函数,2、它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,3、装饰器的返回值也是一个函数对象4、使用 :用@5、一般装饰器函数都被命名为wrapper()“”""""初级装饰器"""def debug(func): def...原创 2019-06-12 11:32:51 · 162 阅读 · 0 评论 -
python--closure闭包
python–closure闭包1、就是当某个函数被当成对象返回时,夹带了外部变量,就形成了一个闭包2、闭包函数相对与普通函数会多出一个__closure__的属性里面定义了一个元组用于存放所有的cell对象,每个cell对象一一保存了这个闭包中所有的外部变量例子def make_printer(msg): def printer(): print(msg) ...原创 2019-06-12 11:29:37 · 239 阅读 · 0 评论 -
python __list的总结
python __list的总结1 len() 长度2、.append(obj) 增加一个3、.count(obj) 某元素的个数4、list.extend(list2) == list+list25、list(seq) 列表变成元组6、遍历1 for data in datas :2 for index ,line in enumerate (all_data)7 ls...原创 2019-06-12 11:19:28 · 164 阅读 · 0 评论 -
python--re模块
python–re模块1、常用例子:pattern = re.compile('<dd>.*?board-index.*?>(\d+)</i>.*?data-src="(.*?)".*?name"><a' + '.*?>(.*?)</a>.*?star">(.*?)</p&...原创 2019-06-12 11:18:11 · 165 阅读 · 0 评论 -
python-file、文件的总结
python–file(文件)的总结from contextlib import closingimport requests#使用yield迭代def read_file(fpath): BLOCK_SIZE = 1024 with open(fpath, 'rb') as f: while True: block = f.r...原创 2019-06-12 11:12:34 · 163 阅读 · 0 评论 -
python-m3u8-协程-快速下载并合并MP4
python-m3u8-协程-快速下载并合并MP4一、关于m3u8:m3u8是苹果公司推出一种视频播放标准,是m3u的一种,不过 编码方式是utf-8,是一种文件检索格式,将视频切割成一小段一小段的ts格式的视频文件,然后存在服务器中(现在为了减少I/o访问次数,一般存在服务器的内存中),通过m3u8解析出来路径,然后去请求。例子:#EXTM3U#EXT-X-VERSION:3#EXT...原创 2019-06-15 20:03:04 · 3171 阅读 · 2 评论 -
pyecharts x轴不能完全显示的问题解决
pyecharts x轴不能完全显示的问题解决 .set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle=subtitle),xaxis_opts=opts.AxisOpts(name_rotate=60,name="123456",axislabel_opts={"rotate":45}))关键代码axislabe...原创 2019-08-25 23:36:30 · 14278 阅读 · 28 评论