Python 3-minute entry, python 3-minute
1. Configure the Python environment (version 2.7 ):
Python Official Website: https://www.python.org/
Pycharm http://www.jetbrains.com/pycharm/download
Note: It is enough for individuals to download and install the community version ~
Install Python after the download (remember to add Python to the environment variable OH ~)
2. Python file type:
When the Python interpreter executes the Python code, it goes through the following stages:
1) load the code file
2) translate to AST (intermediate result obtained by syntax analysis)
3) generate bytecode
4) execute bytecode on PVM (python virtual machine). PVM is actually a stack-based virtual machine. (Similar to JAVA's processing mechanism)
Python can also be executed on different platforms
3. Basic Python syntax
1) code indent: the most distinctive feature of Python is to use indentation to write modules. (The standard is four-cell indent)
2) multi-line Input: Slash \ divides a sentence into multiple lines for display (the statement contains (), {}, and [], and does not need to use a multi-line connector)
3) quotation marks: single quotation marks ('), double quotation marks ("), and three quotation marks (") are used to represent strings.
4) Comment: Use # (press ctrl +/) to comment the lines to be commented on in batches. Press ctrl +/
5) identifier: name given to variables, constants, functions, statement blocks, etc. during programming (the identifiers in Python are case-insensitive)
6) multiple statements are displayed in the same row: Use semicolons (;) to separate statements.
4. user input
Raw_input () and input () are both built-in functions of python and interact with users by reading input from the console. (To put it bluntly, if a = raw_input is defined, you can enter the value of a on the keyboard)
Difference between raw_input () and input:
1) raw_input () treats all input as strings and returns the string type.
2) raw_input () directly reads the input from the console without the type restriction. input () must be a valid python expression. If the input string is, it must be enclosed in quotation marks. Otherwise, it will cause SyntaxError.
3) input () is implemented by raw_input () in essence. It only calls the eval () function after raw_input () is called. Therefore, you can even use the expression as input () and it calculates the value of the expression and returns it.
Example:
Raw_input_A = raw_input ("raw_input:")
Input_A = input ("Input:") (error)
Type (input_A)
5. Python Variables
1) variable value assignment: no declaration is required. The left side of the equal sign (=) operator is a variable name, and the right side of the equal sign (=) operator is the value stored in the variable.
2) assign values to multiple variables: a = B = c = 1 d, e, f = 2, 3, and "john.
6. Python Variable Classification
1) immutable variables: Numbers, tuples (), and strings (when the value is changed, it will point to a new address)
2) variable: list [], Dictionary {} (value change, id unchanged)
Note: we will talk about the above types in the next section ~
This is also a summary of Python. If you have any questions, please point out that you are looking forward to sharing your learning experience ~