Basic Python knowledge

Source: Internet
Author: User

1.2 interactive Interpreter

1.4 numbers and expressions

Integer, floating point, long integer

Division, hexadecimal, octal, etc.

The literal values of Python include: integer, long integer, floating point, compound (plural), string, and Unicode. For more information, see the relevant manual.

1.5 Variables

In python, you only need to attach a value to a variable without declaring the variable and data type.

1.6 statement

Omitted

1.7 obtain user input

You can use input to read the original input type:

Input reads an expression value. You can see that,When inputting a string, it must be "abcdefg", and the quotation marks cannot be removed..
 

1.8 Functions

For some functions, see the function list.

Module 1.9

In python, A py file is a module. To use functions in the module, you must import the module as follows:

 
Functions in the math module cannot be called before being imported, even with math.

Math defines some common mathematical functions.

If you do not use math. xxx every time, you can use the from module import XXX function statement.

1.9 cmath and plural

For a module of the plural number, in Python, the complex number is represented by J.

1.11 string

 
1) The single quotation marks and double quotation marks of a python string are the same. Note that they are different when the string itself contains single or double quotation marks. Note that escape characters are used.

2) Difference between STR and Repr

STR converts the value to a string in a reasonable form so that you can understand

Repr creates a string that represents the value in a valid Python expression.

Let's take a look at this code ~~~~~

3) differences between input and raw_input:

As mentioned above, raw_input treats all input data as raw data and puts it into a string. Let me know this sentence.

4) long string, original string, Unicode

Long String:
 

''' ...... ........''' Can be segmented.

\ Newline

Original string:

Add R before the string to represent the original string, which is useful when the string itself contains escape characters, such as a string like R 'C: \ python'

Unicode string:

U'string'

For more information about Unicode, a common string stores one character in 8-bit ASCII code, while a Unicode Character stores it in 16-bit format and can represent more characters.

Bytes -------------------------------------------------------------------------------------------------------------------------------

Summary:

Literal type

Operator

String

Module, function, input, etc.

Very easy, mainly to experience the characteristics of Python. Next we will learn the built-in data types.

 

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.