Python Learning notes (4)

Source: Internet
Author: User

    1. Expression in parentheses () , square bracket [] , and curly braces {} can span multiple lines.
    2. A backslash () at the end of the line \ denotes continuation to the next line. This is a old rule and was not a recommended as it is error-prone.

A Compound statement, such as def (function definition), while -loop, begins with a header line terminated with a colon ( :); followed by the indented body block. Python does not specify how much indentation to use, but all statements of the body block must start at the same distance From the right margin.

In Python, 0 , and None empty value (such as empty string, empty ‘‘ "" list [] , empty tuple () , empty dic Tionary {} ) is treated as False ; anything else is treated as True . Booleans can also act as integers in arithmetic operations with for and for 1 True 0 False .

Python is dynamic typed. IT Associates types with objects, instead of variables. That's, a variable does not having a fixed type and can be assigned an object of any type. A variable simply provides a reference to an object.

You don't need to declare a variable. A variable is created automatically if a value is first assigned, and which link the variable to the object. You can use built-in function to type(var_name) get the object type referenced by a variable.

Python does not support increment ( ++ ) and decrement ( -- ) operators (as in C/c++/java). You need to use i = i + 1 or for i += 1 increment.

import module_nameStatement:to refer to a attribute, use module_name.attr_name .

from module_name import attr_nameStatement:you can use attr_name directly without the module_name .

from module_name import *Statement:import all attributes of the module.

Python Learning notes (4)

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