#利用collections模块的Counter()函数直接作出统计 #依次加载三个模块 import string,random,collections x = string.ascii_letters + string.digits y = ''.join([random.choice(x) for i in range(1000)]) count=collections.Counter(y) for k,v in sorted(count.items()): print(k,':',v) print('学号:3008')
import string,random,collections
x = string.ascii_letters + string.digits
y = ''.join([random.choice(x) for i in range(1000)])
count=collections.Counter(y)
for k,v in sorted(count.items()):
print(k,':',v)
print('学号:3008')
结果如下图所示
标签:count,字符,string,get,random,collections,print,2.11,1000 From: https://www.cnblogs.com/fang---/p/18467873