In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you why Python is so popular, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1000 readers have 1000 Hamlets in their hearts, asking 1000 programmers "what is the best language?" Java, Python, PHP, and C++ all have their own places. But if you want to ask the king of programming language popularity index, it really belongs to Python.
According to StackOverflow data, Python is a programming language with rapid growth in usage.
According to a new report released by Forbes, the use of python increased by 456 per cent last year. Netfix, IBM, and hundreds of other companies are using python. Including Dropbox is also created by python. Dice's research shows that python is one of the most popular skills in the world, and python is also a popular programming language according to the popularity index of programming languages.
Why is Python so charming?
That's because Python has the following five advantages over other programming languages:
1. Compatible with mainstream platforms and operating systems.
2. Contains many open source frameworks and tools.
3. The coding is readable and maintainable.
4. Powerful standard library
5. Standard test-driven development
Python is becoming more and more popular because of its low learning threshold and broad development prospects.
Python uses tips
1. Working with lists with ZIP
Suppose you want to merge lists of the same length and print the results. There is also a more general way to get the desired result with the zip () function, as follows:
Countries= ['France','Germany','Canada']
Capitals= ['Paris','Berlin','Ottawa']
Forcountry,capitalinzip (countries,capitals):
Print (country,capital) # FranceParis
GermanyBerlin
CanadaOttawa
two。 Use pythoncollections
Pythoncollections is the container data type, namely, lists, collections, tuples, dictionaries. The Collections module provides high-performance data types that enhance the code, making the work simpler and easier. It also provides many features, which are demonstrated using the Counter () function below.
The Counter () function takes an iterable object, such as a list or tuple, and returns an Counter dictionary. The key of the dictionary is the only element that exists in the iterator, and the value of each key is a count of the number of times that element appears in the iterator.
To create a Counter object, pass an iterative (list) to the Counter () function as follows.
FromcollectionsimportCountercount=Counter (['axiomagenics, cedars, cedars,'])
Print (count) # Counter ({'bizzhuahuajiaoguo) ({' bizzhuahuajiaoguo)
3. Use itertools
Python's itertools module is a collection of tools for working with iterators. Itertools includes a variety of tools for generating iteratable results of input data. Take itertools.combinations () as an example. Itertools.combinations () is used to build the composition. These are possible combinations of inputs.
Give a real-life example to illustrate the above point:
Suppose there are four teams in a tournament, and in the league stage, each team has to play against every other team. The task is to list the possible combinations of all the competing teams.
The code is as follows:
Importitertools
Friends= ['Team1','Team2','Team3','Team4']
List (itertools.combinations (friends,r=2)) # [('Team1','Team2'), (' Team1','Team3'), ('Team1','Team4'), (' Team2','Team3'), ('Team2','Team4'), (' Team3','Team4')]
It is important to note that the order of values is not important. Because ('Team1','Team2') and (' Team2','Team1') represent the same pair, the output list needs to include only one of them. Similarly, you can use itertools.permutations () and other functions from the module.
The above is why Python is so popular. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.