使用collection 中counter 类

import collections
import string
import random
res= string.ascii_letters + string.digits + string.punctuation
y = [random.choice(res) for i in range(1000)]
res = collections.Counter(y)
print(len(y))
print(res)

python 生成包含1000个随机数字字符的字符串,然后统计每个数字的出现次数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案