Home >Backend Development >Python Tutorial >Which one is more commonly used, python2 or 3?
The language was born in the 1990s. It is already a 25-year-old uncle-level language by now (there is also a famous java in the same era, which was released in 1995 and became popular a few times. Ten years). But Python’s real fame came many years later than Java. In fact, it was mainly due to the changes in the application field. (guess why, yes, the emergence of big data)
Python2
is a very important version of Python. The earliest version started in 2001, especially the release of py2.5 starting in 2006. The functions of python It gradually became stronger and stabilized, and one version was added every 1-2 years. It slowly became popular around 2008. Python3 was first released in 2008, but the version of py3.0 was very different. It is stable, so the community updates quickly, every few months. So not many people used it at the beginning. It was only when python3.4 was delivered in the spring of 2014 that it began to slowly stabilize. Let’s look at a piece of data below. This is a piece of data compiled by the Python community and some websites in 2014. The survey, regarding Python2/3, some results are as follows:
1).97.51% of users are still writing Python2 code
2).60% of users are writing Python3 code
3).78.09% of users write more Python2 code
4).77.09% of users recognize Python3. Currently, some operating systems in Linux already use Python3 by default:
1).Arch Linux (lightweight Linux operating system)
2).Ubuntu 16.04 (a desktop application-based Linux operating system)
3).Fedora (Redhat desktop version Continuation)
Related recommendations: "python video tutorial"
2. The main difference between Python2 and Python3:
The latest data is that Python has two versions: one is version 2.7.12 and the other is version 3.5.12. So Python2 runs well, why is Python3 suddenly released? In fact, it is to solve some of the history in Python2 The first problem is about strings:
1. Chinese text and binary data are a mess. It is ambiguous whether str in Python represents binary data or text data. Text can represent both text data. It is troublesome to represent binary data, and it is difficult for us to realize when such errors occur. The second is support for Unicode. Since Python was released as open source in February 1991, this means that it preceded the first version of the Unicode standard, which was released in October 1991. In the next few years, languages that emerged later than the Unicode standard chose to implement their own str type on the basis of supporting Unicode encoding, which put Python 2 in an awkward position. Currently, we are in an era where python2/3 coexist, and these two versions are incompatible.
2. python2 is currently only doing bug fixes and maintenance related to new hardware and operating system compatibility. No new features will be added, and python2 will only be supported until 2020. Now Python is evolving towards version 3. During the evolution process, a large amount of code for the 2.x version needs to be modified before it can run, so there are currently many Third-party libraries are temporarily unavailable on 3.x. But you can think about it, maybe the situation will be much better in a few years. After all, there are many excellent programmers around the world migrating some libraries from Py2 to Py3.
3. The choice still depends on your own If the requirement is enterprise development, it must meet the work needs, especially if the dependent software can only run under Python2, Python2 is the first choice. For example, your development needs to rely on a large number of third-party libraries (because one of the reasons why learning Python is very important is It has thousands of third-party packages), such as a large number of data analysis and scientific calculations, so choose Python2. If you study and research by yourself and are willing to embrace changes, then it is recommended to learn Python3, because it is the direction of the future. .Conclusion: Programming is actually mainly about the understanding of programming ideas and the accumulation of experience. Don’t waste a lot of time just because you are confused about whether to learn Py2 or Py3.
4. The ideas in Py2 and Py3 are basically the same, and the moves are similar. When you are familiar with Python to a certain program, it only takes a short time for someone who knows Py2 to learn Py3. So don’t waste precious learning time by worrying about minute grammatical differences. Okay, that’s it for the grievances between Python2 and Python3 (they will still love and kill each other for a while). I hope it can give some inspiration to beginners. If you don’t understand anything, you can also leave a message with me to discuss and communicate.
The above is the detailed content of Which one is more commonly used, python2 or 3?. For more information, please follow other related articles on the PHP Chinese website!