摘要:
from collections import Counterimport retxt = open('app.py').read()print Counter(re.split('\W+',txt)).most_common(3) re.split('\W+',txt)表示以非单词字符划分。 阅读全文
posted @ 2017-08-09 15:05
赭山东路
阅读(96)
评论(0)
推荐(0)
摘要:
l为有重复元素的列表。 方法一: 可以简单的使用l = list(set(l)) 去重 方法二: fromkeys用法:dict.fromkeys(seq[, value])),value默认是None 说明:创建并返回一个新字典,以序列seq中元素做字典的键,val为字典所有键对应的初始值(默认为 阅读全文
posted @ 2017-08-09 14:49
赭山东路
阅读(211)
评论(0)
推荐(0)
摘要:
data = [randint(0,20) for _ in xrange(30)]表示30个随机生成的0-20随机数其中for _ in xrange(30)表示循环30次。 from random import randintprint {x: randint(60,100) for x in 阅读全文
posted @ 2017-08-09 14:24
赭山东路
阅读(198)
评论(0)
推荐(0)

浙公网安备 33010602011771号