10 min To learn python basic syntax 01

Source: Internet
Author: User
Tags python script

# Python website: http://www.python.org/

# tuple is identified with () identifier, list with [] identifier, dictionary with {}

# unless there is a special need for input, you should try to use the Raw_input function as much as possible

# Change terminal font color and model: http://blog.csdn.net/gatieme/article/details/45439671

# # After the items for each part of the title, the content can be directly indexed according to the title

# # A, the premise of the matter

# # Two, programming mode

# # three, basic format

First, the premise matters:

1. Skip the download, installation and environment variable configuration process, need to configure Python to refer to the Novice tutorial

2. Enter Python directly under the Linux operating system to view the current version number, enter Quit () (or CTRL + D) to exit edit mode

3. Some preconditions, if it is 2. X low version Python to print Chinese characters, you need to add them at the beginning of the file

#-*-coding:utf-8-*-or

#coding =utf-8

Second, the programming mode:

1. Interactive Programming:

On Linux, you can start interactive programming by simply entering the Python command on the command line:

2. Scripted Programming:

Use the editor to write a simple Python script, and all Python files will have a. py extension.

Three, the basic format:

1. Identifiers:

Identifiers in Python cannot start with a number and are case-sensitive.

2. Reserved words:

3. Line and indent:

Python's code blocks do not use curly braces to control classes, functions, and other logical judgments. Python uses indentation to write modules. The blank length of the indentation is variable, but all code block statements must contain the same indentation white space length.

4. Multi-line statements:

A new line is generally used as the Terminator for a statement in a Python statement. But we can use a slash (\) to divide a line of statements into multiple lines of display.

5.python notes:

A single-line comment in Python starts with #.

A multiline comment in Python uses three single or three double quotation marks.

6.python Blank line:

For later maintenance and refactoring of code, there is usually a blank line between functions or methods of the class, and empty lines are not part of the Python syntax, but blank lines are part of the program code.

7. Write more than one statement on the same line:

Python can use more than one statement in the same row, separated by semicolons.

10 min To learn python basic syntax 01

Related Article

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.