I haven't written an article for a long time. I recently prepared a Python website and reviewed it. Since I wrote an article, I wrote it according to the specifications on the official website.
You are welcome to point out something wrong.
I. logical and physical rows
A Python program analyzes a symbolic (TAG) stream through a syntax analyzer. It is composed of a series of logical rows, which are composed of one or more physical rows.
What is logic? A logical line is a statement that implements a function.
a = 1print(3)
The above example explains: Here a = 1, assigning a value to a is a logical line; printing a number 3 on the screen is also a logical line.
A physical row is an integral part of a logical row, because a logical row may consist of several physical rows.
print3
In the preceding example, print is a physical row, and 3 is a physical row, which forms a logical row.
However, in the if Condition Statement, assume that there are two conditions: 1> 0 and 2> 0. if yes, output 3. Therefore, the two conditions cannot be directly separated.
You can write it as follows:
If 1> 0 \ # Or if 1> 0 and \ and 2> 0: #2> 0: print (3) # print (3)
In the preceding example, an explicit row connection ("\") is added after and, which helps two physical rows join together to form a logical row.
In addition, # is used in python to annotate the code.
Ii. indentation
In Python, there are two kinds of indentation: one is to press a space, and the other is to press the tab key.
The Python syntax stipulates that the first line of a program cannot contain spaces.
The tab key contains eight spaces (this is the same in UNIX as it was found when I was bored. You can count it if you don't believe it ~ _~).
Iii. Literal
Here we will give a general explanation of the expressions of numbers, texts, symbols, and other texts.
1. escape characters:
The escape characters inherit the C style in python. The common \ n, \ B, \ t are used in the same way as C.
2. Integer:
Decimal: "1"... "9"... "0"
Octal: "0" ("o" | "O") "1"... "9" "0"
Binary: "0" ("B" | "B") "1"... "9" "0"
Hexadecimal: "0" ("x" | "X") "1"... "9" "0"
3. floating point float:
There are several forms, 3.14 10 .. 001 1e100 3.14e-10 0e0
4. Plural:
In python, there are also such types as: 3.14j, 10.j, 10j,. 001j, 1e100j, 3.14e-10j
5. operators:
+ - * ** / // %<< >> & | ^ ~< > <= >= == !=
Iv. Summary
Let's talk about the python syntax first. In the next article, I will describe details about the python data type.