In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
 
            
                     
                
2025-11-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Python to calculate a person's constellation". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use Python to calculate a person's constellation"!
Pass the month and date of birth into this function, and you can get the corresponding constellation. Of course, this is only a very simple first step. Next, let's calculate which star sign has the most people in the top 100 of the global rich list in 2012. Hee hee, do you expect it?
1. Get data
There is a post on Douban that helps us list the corresponding data, but in the form of text:
Https://www.douban.com/group/topic/28671832/
 
Fortunately, there is a unified format, and we can extract the date of birth with regular expressions:
(\ d +)? Month? (\ d +)? Day
In Vscode, you can also directly replace it with a pattern to become the tuple we want:
Click enter to replace it with a tuple. In the end, we will find that there are only 88 birth dates, it doesn't matter, it's enough for our experiment.
two。 Put the code into the calculation
Put all the dates you got earlier into an array, and then call the constellation calculation function we said at the beginning, of course, you need to use a dictionary to calculate the occurrence of each constellation:
Because there is too much data here, I didn't cut it up. Interested friends can Python practical treasure official account background reply constellation tycoon calculation to get all the data and code.
The results are as follows:
{Aquarius: 7, Scorpio: 7, Virgo: 8, Pisces: 7, Aries: 12, Leo: 8, Libra: 5, Taurus: 9, Cancer: 1, Gemini: 5, Capricorn: 3, Sagittarius: 4}
Let's make a sequence:
Print (sorted (result.items (), key=lambda item: item [1]))
Results:
(cancer, 1), (Capricorn, 3), (Sagittarius, 4), (Libra, 5), (Gemini, 5), (Aquarius, 7), (Scorpio, 7), (Pisces, 7), (Virgo, 8), (Leo, 8), (Taurus, 9), (Aries, 12)]
At this point, I believe you have a deeper understanding of "how to use Python to calculate a person's constellation". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about

The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r


A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from

Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





 
             
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.