
python
Levy_Y
浩淼宇宙,为何我们在此相遇。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python乱码 b'\x1f\x8b\x08\x00\x00\x00\x00\x00\...'
Python里面的编码问题真的让人快疯了..比如res打印出来是这个b’\x1f\x8b\x08\x00\x00\x00\x00\x00…’import gzipret = gzip.decompress(res).decode("utf-8")搞定!原创 2018-08-09 11:09:19 · 38601 阅读 · 14 评论 -
Python函数超时装饰器
有回调函数的超时装饰器# 有回调函数的超时报错装饰器import signalimport timedef set_timeout(num, callback): def wrap(func): def handle(signum, frame): # 收到信号 SIGALRM 后的回调函数,第一个参数是信号的数字,第二个参数是the interrupted ...原创 2018-10-31 14:50:21 · 1153 阅读 · 1 评论 -
python给字典的键添加动态列表
python给字典的键添加动态列表前言:终于能用python实现这个功能了,用来处理流数据非常有用。在输出K—means聚类结果时也非常好用!!def addWord(theIndex,word,pagenumber): theIndex.setdefault(word, [ ]).append(pagenumber)#存在就在基础上加入列表,不存在就新建个字典key d = {"...原创 2018-11-28 22:29:26 · 3633 阅读 · 3 评论