Python中统计输入字符的个数

Python中这个功能主要使用了count()这个函数,具体实现代码如下:


content = input("请输入一串字符串:")
res = {}
for i in content:
    res[i] = content.count(i)
print(res)

猜你喜欢

转载自blog.csdn.net/qq_33567641/article/details/80917162