Python 3 Tutorial

Source: Internet
Author: User
Tags python script

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
    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.