5.2 Assignment Magic:
5.2.1 Sequence Unpacking: It allows the function to return more than one value and package the Narimoto group, which is then easily accessible through an assignment statement. The number of elements in the unpacked sequence must be exactly the same as the number of variables placed on the left of the assignment symbol =, otherwise an exception will occur.
5.2.2 Chain Assignment: Assign a value to multiple variables.
5.2.3 Increment Assignment: +=,*=
5.3 Indent:
5.4 Items and Conditional statements:
False: false,none,0, "", (), [],{}.
Conditional execution And if statement, Else statement, Elif statement
To sum up: use the = = operator to determine whether two objects are equal, using is to determine whether the two are equal (the same object).
Assertion (Assert): If you need to make sure that a condition in your program must be true for your program to work, it can place checkpoints in your program. After a condition, you can add a string to interpret the assertion.
5.5 Cycles:
Some iterative tools: 1, parallel iteration (Zip function), zip can cope with unequal sequences, when the shortest sequence runs out of time will stop.
The range function creates an entire sequence at a time, and the Xrange function creates one number at a time.
2, number iteration (enumerate function)
3. Flip and sort iterations (reversed and sorted), instead of modifying the object in situ, return the flipped or sorted version
Jump out of the loop: 1, break
2, continue, let the current iteration end, "Jump" to the beginning of the next round of the cycle. That is, "skips the remaining loop body, but does not end the loop."
5.6 List Derivation:
5.7 Threesome:1, nothing happened (pass)
2. Delete by using Del, delete only the name, not the list itself.
3. Execute and evaluate strings using exec and eval: 1. The statement executing a string is exec
2. Eval evaluates the Python expression (written in string)
Basic Python Tutorial (5)