One, the print statement
1.1 Basic output, automatic branch
1.2 Print comma, you can join the previous content without wrapping, in a row
1.3 >> Redirect, output to file print >> filename, "What to enter"
Ii. Control Flow Statements
2.1 consists of the condition and execution code block . Conditions can be divided into decisions , loops , and branches
2.2 Format (colon with 4 empty Geyong not forgotten)
2.3 If and for functions are control flow
Three, Boolean value
3.1 Lazy evaluation, circuit breaker logic
3.2 From left to right, binate to the back, there is a false return, the latter will not be executed (the easy-to-appear judgment in front, not easy to appear in the back)
3.3 Control flow and true and false values are closely related, do not misunderstand the true and False and Boolean value
3.4 Some of the most basic operators of Boolean values
and
Or
Is check share
= = Check Value
Not
Several other comparison symbols
3.5 Use small tricks, or default values. From_url = Url.get (' from ') or None
Iv. If statement (Control flow statement)
4.1 Basic format of IF
If expression: #条件表达式 Expresson result, must be true
Statement (s)
4.2 If and if else elif pass
4.2.1 if and elif instead of switch
4.3 Ternary expression 4 if True else 3
Five. While statement
Basic format for 5.1 while
While Expresson:
Statement (s)
Basic components of the 5.2 while
5.2.1 Break End While
5.2.2 continue jumps out of the current loop but does not end while
5.2.3 Else ends while executing
5.3 Note: In general applications, the while must give an end condition, otherwise it is the legendary death cycle
VI. For statement
6.1 for basic format
For item in Iterable:
Statement (s)
Basic components of 6.2 for
6.2.1 Break
6.2.2 Continue
6.2.3 Else
6.3 Note: The last iteration value of the for is preserved
PS: Loop statement else cannot be used with break
Python Self-study notes (eight) Python statement