Home>Article>Backend Development> How to count the number of different characters in Python

How to count the number of different characters in Python

藏色散人
藏色散人 Original
2021-05-19 15:18:44 29972browse

How to count the number of different characters in python: first create a py sample file; then count the number of different characters through the "for i in str:resoult[i]=str.count(i)" method That’s it.

How to count the number of different characters in Python

The operating environment of this article: Windows 7 system, python version 3.6.4, Dell G3 computer.

Python--Counting the number of characters in a string

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

I have to marvel at the power of Python’s built-in functions

How to count the number of different characters in Python

Related free Learning recommendation:python video tutorial

The above is the detailed content of How to count the number of different characters in Python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn