最直观的用dict
for x in s:
if x in dict:
dict[x] += 1
else:
dict[x] = 0
利用 Counter
import collections
c = collections.Counter(s)
利用 dict.get
for i in range(n):
substr = s[i:i+10]
d[substr] = d.get(substr,0) + 1#这里利用get就不用判断key是否存在了,如果不存在会返回0