Introduction to Python
Development History
Python 2 or 3?
1. Introduction to Python
The founder of python is Guido van Rossum. During the Christmas period of 1989, in order to kill time in Amsterdam, Guido van Rossum decided to develop a new script interpreter as a successor to the ABC language.
#In the latest TIOBE rankings, Python has overtaken PHP to occupy the fifth place. Python advocates elegance, clarity, and simplicity, and is an excellent and widely used language.
Python can be used in many fields, such as: data analysis, component integration, network services, image processing, numerical computing and scientific computing and many other fields. At present, almost all large and medium-sized Internet companies in the industry are using Python, such as: Youtube, Dropbox, BT, Quora (China Zhihu), Douban, Zhihu, Google, Yahoo!, Facebook, NASA, Baidu, Tencent, Autohome, Meituan et al. Things that Internet companies widely use Python to do generally include: automated operation and maintenance, automated testing, big data analysis, crawlers, Web, etc.
Currently Python’s main application areas:
Cloud computing: the most popular language for cloud computing, typical application OpenStack
- ##WEB Development: Many excellent WEB frameworks, many large websites are developed in Python, including Youtube, Dropbox, and Douban. . . , Typical WEB frameworks include Django
- Scientific operations, artificial intelligence: Typical libraries NumPy, SciPy, Matplotlib, Enthought libraries, pandas
- System operation Wei: One of the essential languages for operation and maintenance personnel
- Finance: quantitative trading, financial analysis, in the field of financial engineering, Python is not only used, but also used the most, and its importance is increasing year by year. . Reason: As a dynamic language, Python has a clear and simple language structure, rich libraries, mature and stable, efficient scientific calculation and statistical analysis, and its production efficiency is much higher than that of c, c++, and java. It is especially good at strategy backtesting
- Graphic GUI: PyQT, WxPython,TkInter
Regarding speed: high-level languages cannot compare with C in terms of running speed
For speed: Python may be slightly inferior in speed
- Python's positioning is "elegant", "clear", and "simple", so Python programs always look simple and easy to understand. Beginners learning Python are not only easy to get started, but also can write very, very complex programs if they go deeper in the future.
- The development efficiency is very high. Python has a very powerful third-party library. Basically, if you want to realize any function through the computer, the official Python library has corresponding modules to support it. Download it directly. After the call, development is carried out on the basis of the basic library, which greatly reduces the development cycle and avoids reinventing the wheel.
- High-level language————When you write a program in Python, you don’t need to think about low-level details such as how to manage the memory used by your program
- Portability - Due to its open source nature, Python has been ported to many platforms (with modifications to enable it to work on different platforms). If you carefully avoid using system-dependent features, then all of your Python programs can run without modification on almost any system platform on the market
- Scalability———— — If you need a critical piece of your code to run faster or want certain algorithms to be kept private, you can write parts of your program in C or C++ and use them in your Python program.
- Embeddability - You can embed Python into your C/C++ program to provide scripting functionality to your program users.
Slow speed. Python runs much slower than C language and slower than JAVA. Because Python is an interpreted language, your code will be translated line by line during execution. into machine code that the CPU can understand. This translation process is very time-consuming, so it is very slow. The C program is directly compiled into machine code that the CPU can execute before running, so it is very fast. But in fact, the slow running speed referred to here cannot be directly perceived by users in most cases, and must be reflected with the help of testing tools.
The code cannot be encrypted because PYTHON is an interpreted language and its source code is stored in text form. However, I don’t think this is a disadvantage. If your project requires source code The code must be encrypted, then you shouldn't use Python to implement it in the first place.
Threads cannot take advantage of the problem of multiple CPUs. This is the most criticized shortcoming of Python. GIL is the Global Interpreter Lock (Global Interpreter Lock), which is used by computer programming language interpreters. A tool for synchronizing threads so that only one thread is executing at any time. Python threads are native threads of the operating system. It is pthread on Linux and Win thread on Windows. The execution of the thread is completely scheduled by the operating system. A python interpreter process has a main thread and multiple user program execution threads. Even on multi-core CPU platforms, parallel execution of multi-threads is prohibited due to the existence of GIL. Regarding the compromise solution to this problem, we will discuss it in detail in the thread and process chapters later.
Types of Python
When we write Python code, what we get is a Python code containing A text file with a .py extension. To run the code, you need the Python interpreter to execute the .py file.
Since the entire Python language is open source from specification to interpreter, in theory, as long as the level is high enough, anyone can write a Python interpreter to execute Python code (of course it is very difficult). In fact, multiple Python interpreters do exist.
CPython
After we downloaded and installed Python 2.7 from the official Python website, we directly got an official version of the interpreter: CPython. This interpreter is developed in C language, so it is called CPython. Running python from the command line starts the CPython interpreter.
CPython is the most widely used Python interpreter. All code in the tutorial is also executed under CPython.
IPython
IPython is an interactive interpreter based on CPython. That is to say, IPython is only enhanced in the interactive mode, but the function of executing Python code is completely the same as CPython. the same. For example, although many domestic browsers have different appearances, their cores actually call IE.
CPython uses >>> as the prompt, while IPython uses In [serial number]: as the prompt.
PyPy
PyPy is another Python interpreter that targets execution speed. PyPy uses JIT technology to dynamically compile Python code, so it can significantly improve the execution speed of Python code.
Most Python codes can be run under PyPy, but there are some differences between PyPy and CPython, which results in the same Python code executing under the two interpreters may have different results. If your code is to be executed under PyPy, you need to understand the differences between PyPy and CPython.
Jython
Jython is a Python interpreter running on the Java platform. It can directly compile Python code into Java bytecode for execution.
IronPython
IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft .Net platform and can directly compile Python code into .Net bytecode.
Summary
There are many Python interpreters, but the most widely used one is CPython. If you want to interact with Java or .Net platform, the best way is not to use Jython or IronPython, but to interact through network calls to ensure the independence between programs.
2. History of Python development
- ## In 1989, in order to pass the Christmas holiday, Guido began to write Python language translater. The name Python comes from Guido’s beloved TV series Monty Python’s Flying Circus. He hopes that this new language called Python can meet his ideal: to create a language between C and shell that is comprehensive, easy to learn, easy to use, and scalable.
- In 1991, the first Python compiler was born. It is implemented in C language and can call C language library files. From its birth, Python has had: classes, functions, exception handling, core data types including tables and dictionaries, and a module-based expansion system.
- Granddaddy of Python web frameworks, Zope 1 was released in 1999 ##Python 1.0 - January 1994 added lambda, map, filter and reduce .
- ##Python 2.0 - October 16, 2000, added a memory recycling mechanism, forming the basis of the current Python language framework
- Python 2.4 - November 30, 2004, the same year that the most popular WEB framework Django was born
- Python 2.5 - September 19, 2006
- Python 2.6 - October 1 , 2008
Python 2.7 - July 3, 2010
In November 2014, it was announced that Python 2.7 would be supported until 2020, and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possible
Python 3.0 - December 3, 2008
Python 3.1 - June 27, 2009
Python 3.2 - February 20, 2011
Python 3.3 - September 29, 2012
Python 3.4 - March 16, 2014
Python 3.5 - September 13, 2015
三、Python 2 or 3?
In summary : Python 2.x is legacy, Python 3.x is the present and future of the language
Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of
extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is
under active development and has already seen over five years of stable releases, including version 3.3 in 2012,
3.4 in 2014, and 3.5 in 2015. This means that all recent standard library improvements, for example, are only
available by default in Python 3.x.
Guido van Rossum (the original creator of the Python language) decided to clean up Python 2.x properly, with less regard for backwards compatibility than is the case for new releases in the 2.x range. The most drastic improvement is the better Unicode support (with all text strings being Unicode by default) as well as saner bytes/Unicode separation.
Besides, several aspects of the core language (such as print and exec being statements, integers using floor pision) have been adjusted to be easier for newcomers to learn and to be more consistent with the rest of the language, and old cruft has been removed (for example, all classes are now new-style, "range()" returns a memory efficient iterable, not a list as in 2.x).
py2与3的详细区别
PRINT IS A FUNCTION
The statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old statement (PEP 3105). Examples:
Old: print "The answer is", 2*2 New: print("The answer is", 2*2) Old: print x, # Trailing comma suppresses newline New: print(x, end=" ") # Appends a space instead of a newline Old: print # Prints a newline New: print() # You must call the function! Old: print >>sys.stderr, "fatal error" New: print("fatal error", file=sys.stderr) Old: print (x, y) # prints repr((x, y)) New: print((x, y)) # Not the same as print(x, y)!
You can also customize the separator between items, e.g.:
print("There are possibilities!", sep=""
ALL IS UNICODE NOW
从此不再为讨厌的字符编码而烦恼
还可以这样: (A,*REST,B)=RANGE(5)
<strong>>>> a,*rest,b = range(5) >>> a,rest,b (0, [1, 2, 3], 4) </strong>
某些库改名了
Old Name |
New Name |
_winreg |
winreg |
ConfigParser |
configparser |
copy_reg |
copyreg |
Queue |
queue |
SocketServer |
socketserver |
markupbase |
_markupbase |
repr |
reprlib |
test.test_support |
test.support |
还有谁不支持PYTHON3?
One popular module that don't yet support Python 3 is Twisted (for networking and other applications). Most
actively maintained libraries have people working on 3.x support. For some libraries, it's more of a priority than
others: Twisted, for example, is mostly focused on production servers, where supporting older versions of
Python is important, let alone supporting a new version that includes major changes to the language. (Twisted is
a prime example of a major package where porting to 3.x is far from trivial
更多Python学习【第一篇】Python简介 相关文章请关注PHP中文网!

To maximize the efficiency of learning Python in a limited time, you can use Python's datetime, time, and schedule modules. 1. The datetime module is used to record and plan learning time. 2. The time module helps to set study and rest time. 3. The schedule module automatically arranges weekly learning tasks.

Python excels in gaming and GUI development. 1) Game development uses Pygame, providing drawing, audio and other functions, which are suitable for creating 2D games. 2) GUI development can choose Tkinter or PyQt. Tkinter is simple and easy to use, PyQt has rich functions and is suitable for professional development.

Python is suitable for data science, web development and automation tasks, while C is suitable for system programming, game development and embedded systems. Python is known for its simplicity and powerful ecosystem, while C is known for its high performance and underlying control capabilities.

You can learn basic programming concepts and skills of Python within 2 hours. 1. Learn variables and data types, 2. Master control flow (conditional statements and loops), 3. Understand the definition and use of functions, 4. Quickly get started with Python programming through simple examples and code snippets.

Python is widely used in the fields of web development, data science, machine learning, automation and scripting. 1) In web development, Django and Flask frameworks simplify the development process. 2) In the fields of data science and machine learning, NumPy, Pandas, Scikit-learn and TensorFlow libraries provide strong support. 3) In terms of automation and scripting, Python is suitable for tasks such as automated testing and system management.

You can learn the basics of Python within two hours. 1. Learn variables and data types, 2. Master control structures such as if statements and loops, 3. Understand the definition and use of functions. These will help you start writing simple Python programs.

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function