Python 3 Tutorial
Python's 3.0 version, often called Python 3000, or Py3k for short. Compared to earlier versions of Python, this is a major upgrade. In order not to bring too much baggage, Python 3.0 was not designed with backward compatibility in mind.
We have already introduced Python and its installation tutorial in thePython 2.X version tutorial, so we won't repeat it here.
You can also clickDifferences between Python 2.x and 3.x versionsto view the differences between the two.
This tutorial is mainly for learning Python 3.x. If you are using Python 2.x, please move toPython 2.X version tutorial。
It was officially announced that updates to Python 2 would stop on January 1, 2020.
Check Python Version
We can use the following command in the command window (on Windows, press win+R to bring up the cmd run box) to check the Python version we are using:
python -V 或 python --version
The result of executing the above command is as follows:
Python 3.3.2
You can also enter Python's interactive programming mode to check the version:
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>>
First Python 3.x Program
For most programming languages, the first introductory programming code is"Hello World!", the following code uses Python to output"Hello World!":
hello.py file code:
print("Hello, World!")
Run Example »
The common file extension for Python is.py。
You can save the above code inhello.pyfile and use the python command to execute the script file.
$ python3 hello.py
The output of the above command is:
Hello, World!Other Extensions