import string
import random
from collections import defaultdict
#x由数字,字母,其他符号组成
x=string.ascii_letters+string.digits+string.punctuation
print(x)
#从x中随机选100个元素组成z
z=''.join([random.choice(x) for i in range(100)])
print('='*90,'\n',z)
#输出最多的5个
from collections import Counter
frequences=Counter(z)
print('='*90,'\n',frequences.most_common(5))
x:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&’()*+,-./:;<=>?@[]^_`{|}~
frequences.most_common(5):
[(’(’, 4), ("’", 4), (’?’, 4), (’\’, 4), (‘n’, 3)]