.
3ss.cn

python怎么样统计唔使同字符的个数

python统计不同字符的个数的方法:首先创建一个py示例文件;然后通过“for i in str:resoult[i]=str.count(i)”方法统计不同字符的个数即可。

Python–统计字符串中各字符的个数

#统计字符个数
str=input("请输入一串字符:")
resoult={}
for i in str:
    resoult[i]=str.count(i)
print(resoult)

不得不惊叹Python内置函数的强悍

赞(0)
未经允许不得转载:互联学术 » python怎么样统计唔使同字符的个数

评论 抢沙发