In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to count different characters in python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The operating environment of this tutorial: windows7 system, Python 3.9.1 Dell G3 computer.
1. Statistical process
The most important thing is to find a standard to use if sentences to distinguish the characters that need to be counted. Obviously, python3.X can use unicode directly.
Determine the unicode coding range, including Chinese characters, numbers, lowercase letters and uppercase letters.
Make sure there is only one line of output.
Write the code.
2. Examples
N=input ("Please enter a line of characters:") # enter a line of characters a=b=c=d=0#an is the number of letters, b is the number of numbers, c is the number of spaces, d is the number of other characters for i in n:#for loop traversal string n#ord () built-in function, returns the corresponding ASCII value if ord ('a')
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.