python 统计2^2^2^2^2的各数字出现次数

包含的知识点:

1. 拆分字符串

2. 默认字典

>>> import collections
>>> d=collections.defaultdict(int) #注意填参数int
>>> bignum=list(str(2**2**2**2**2)) #list可以拆分字符串为单字符
>>> len(bignum)
19729
>>> for num in bignum:
    d[num]+=1

    
>>> for n in d:
    print(d[n])

    
1972
1948
1978
1984
1903
1977
1983
1984
1943
2057
原文地址:https://www.cnblogs.com/KakagouLT/p/9572241.html