The bottom of the summary is on the Python3.
One. Basis
1. Output and Input:
Output: Print (variable/string)
Enter: input () returns a string
price=input ()print(price)
2.python style
(1) Note #
(2) The general situation is that a line ends the sentence, but if you want to continue, the end of the line is added \
(3) Symbols that do not require line breaks or can be wrapped: ' '
(4) A row can have more than one statement,
3. Identifiers
Basic and Java-like, but also case-sensitive
Key words:
4. Expressions
(1) Determining the type by value
(2) Assigning values in a "reference" manner
(3) Increment operator:+ = = *=/=%= * = <<= >>= &= ^= |=
5.python Data types
(1) (long) Integer: Integral type and long integer type are not strictly differentiated, the integer value after the "L" is the long integer type
(2) Boolean: Only 2 values: True, False, essentially using integer 1, 0, respectively, stored
(3) floating point number: That is, the real number in mathematics, can be similar to scientific notation
(4) plural type: real + imaginary is plural, imaginary part must have J
Complex numbers can separate real and imaginary parts: complex numbers. Real plural. imag
Conjugation of complex numbers: complex numbers. Conjugate ()
(5) String: Single, double, and triple quotes are strings, immutable types
(6) List: powerful type, square brackets [] bounds, mutable type
(7) Tuples: Similar to lists, with parentheses (), immutable types
(8) Mapping type dictionary: curly braces {} bounds, similar to hash table key-value pairs
6 operator
Powers * *, plus sign +-, multiplication */, divisible//, remainder%, plus minus +-
Integer division returns the floating-point number, to get the integer result using//
7. Comparison operations
Comparison of values: by value ratio
Comparison of strings: by ASCII value size
Not equal to "! =" only, "<>" is not supported
8. Logic operation:
Logical operator Precedence: not, and, or
9. Character operators:
Primitive string operator (R/R): – For some places where you do not want the escape character to work
Unicode string operator (u/u): – Converts to a Unicode string
f = open (R'c:\python\test.py','w') = open ( ' c:\python\test.py ','w') #会报错
10 built-in functions
The built-in function does not need import to be used, but not the built-in function requires an import
from Import *print(Floor (-35.4))
Python often uses an "import module" to reuse functions, classes, and the like in off-the-shelf modules into other code blocks
Import Math Print (Math.PI)
Importing multiple modules
Import ModuleName1, ModuleName2, ...
Module to import the specified module attribute, which is the specified name into the current with domain
from Import Moduleelement
11 packs
A hierarchical file directory structure that defines a Python application execution environment consisting of modules and sub-packages
#方式一
Import AAA. CCC.C1AAA.CCC.C1.FUNC1 (123)
#方式二
from Import func1 func1 (123)
12 Library
A library is a set of modules that have related functionality
Two. Aspects of
Python Beginner Summary