Python basic syntax

Source: Internet
Author: User

Identifier
    • The first character must be a letter or underscore ' _ '.
    • The other parts can be letters, numbers, and underscores.
    • Identifiers are case sensitive.
Built-in keywords

They cannot be used as any identifier name. Python's standard library provides a keyword module that can output all the keywords for the current version:

Import keyword

Keyword. Kwlist

Multi-line statements

Python is usually a line to complete a statement, but if the statement is long, we can use a backslash (\) to implement a multiline statement, for example:

=+         item_two

    • Natural string, by adding R or R before the string. such as R "This was a line with \ n \" will be displayed, not newline.

The print default output is newline, and if you want to implement no newline, add end= ""to the end of the variable:
Print( x,end="")      

Import and From...import

Import the appropriate modules in Python using Import or from...import.

Import the entire module (somemodule) in the format: Import module

Import a function from a module in the format: from module Import function

Import multiple functions from a module in the format: from module Import function 1, function 2, function 3

Import all functions in a module in the format: from module Import *

Python basic syntax

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.