Python 3 Tutorial
The 3.0 version of Python, often referred to as Python 3000, or simply py3k. This is a large upgrade relative to earlier versions of Python. In order not to take too much of a burden, Python 3.0 did not consider backwards compatibility when designing.
Python Introduction and Installation tutorial We have introduced in the Python 2.X version of the tutorial, here will not repeat.
You can also click python2.x with 3??. X version difference to see the difference between the two.
This tutorial is for the Python 3.x version of learning, if you are using the Python 2.x version, please move to the Python 2.X version of the tutorial.
View Python version
We can use the following command to view the Python version we are using:
Python-v
The results of the above command execution are as follows:
Python 3.3.2
You can also enter Python's interactive programming mode to view the version:
Python 3.3.2 (V3.3.2:d047928ae3f6, May, 00:03:43) [MSC v.1600"copyright" " credits " or " license () " for More information. >>>
First python3.x Program
For most programming languages, the first starter code is "Hello world! ", the following code is for using Python output" Hello world! ":
Instance (Python 3.0+)
# !/usr/bin/python3 Print ("Hello, world!");
You can save the above code in the hello.py file and execute the script file using the Python command.
$ Python3 hello.py
The above command outputs the result:
Hello, world!.
List of Notes
an understanding of the first line of code #!/usr/bin/python3 in an instance:
is divided into two situations:
(1) If you invoke a Python script, use:
Python script.
#!/usr/bin/python is ignored and is equivalent to a comment.
(2) If you invoke a Python script, use:
./script.
#!/usr/bin/python specifies the path to the interpreter.
Python 3 Tutorial