python高级
defending
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python 统计序列中元素的出现频度\统计英文文章的词频
一:In [28]: data=[random.randint(1,20) for _ in range(30)]In [29]: d = dict.fromkeys(data,0)In [32]: for i in data: ...: d[i] += 1二:In [34]: from collections import CounterIn [原创 2017-12-03 21:29:23 · 412 阅读 · 0 评论 -
根据字典的值大小对字典进行排序
一:In [76]: d = {x:random.randint(60,100) for x in 'abcdefg'}In [86]: l=list(zip(d.values(),d.keys()))In [87]: l=sorted(l)#从小到大排列二:In [97]: d.items()Out[97]: dict_items([('a', 80), ('b',原创 2017-12-03 21:46:54 · 1163 阅读 · 0 评论 -
如何找多个字典的公共健?
In [1]: from random import randint, sampleIn [5]: s1 = {x: randint(1,4) for x in sample('abcdefg', randint(3,6))}In [6]: s2 = {x: randint(1,4) for x in sample('abcdefg', randint(3,6))}In原创 2018-01-09 13:03:52 · 226 阅读 · 0 评论 -
有序字典
from collections import OrderedDictfrom random import randintfrom time import timed = OrderedDict()players = list('asdfghjkl')start = time()for i in range(9): input() p = players.pop(r原创 2018-01-09 13:22:40 · 369 阅读 · 0 评论 -
python3 deque(双向队列)
创建双向队列import collectionsd = collections.deque()append(往右边添加一个元素)import collectionsd = collections.deque()d.append(1)d.append(2)print(d)#输出:deque([1, 2])appendleft(往左边添加一个元素)转载 2018-01-09 13:39:36 · 477 阅读 · 0 评论 -
pdf2image
https://github.com/Belval/pdf2image from pdf2image import convert_from_path, convert_from_bytesimport os, time, sysdef pdf2jpg(): try: image = convert_from_path(sys.argv[1...原创 2018-10-09 10:28:48 · 2004 阅读 · 0 评论
分享