1 cycles
While condition:
Loop body
While True:
Loop body (dead Loop)
For I in range (1,3):
Print (i)
Traverse Hello
For loop traversal
Break jumps out of this layer loop, this layer loop is completely finished
Continue: Jump out of this loop, enter the next cycle of this layer, the code behind continue will not run
3 keys to assigning values
1 There's a space in memory.
There's an ID.
There is a type
has a value
Number is immutable type ID type value
string is immutable type
ID type invariant value changed to be mutable type such as List
List:
List values
Modify the value of a list
Find and Index differences
1-255 only one instance of Python
To save memory
A=300 b=300 is not a thing.
a=200 b=200 refers to a thing
Vim Visualization
Go on
Visualization of Vim
Ctrl + V Enter
Shfit+i Alignment operation
Space
Escesc can
Identity comparison + Type comparison + value comparison
Chained assignment
a=b=c=d=106
Multi-value Assignment
X,y=y,x
Print (X.Y)
Increment assignment
x=10
X+=1 #x =x+1
Decompression sequence Type
s= ' Hello '
_ Represents the discarded value
List values
Cycle
Loop Get list elements
Traverse a list in a list
Idiot Edition
Slice
Append and insert, append add to back, insert insert XX front
Delete, () Add index
Listname.pop () directly delete list last
With a return value.
Queue: FIFO
From left to right
The second Kind
From right to left
Stack
Len can count strings, can count lists
Find Element Index
List elements Count
Extend the element as a whole if
Append append a list as an element
Delete by element
Sort from small to large
Sort from big to small
Simple flip operation will swap left and right
Meta-group
The Ganso element can be any data type, but cannot be changed
t= (' A ', ' B ', 1, (3,4))
Count Statistics number
Index statistics Indexes
Value of Ganso
Tuple's while loop and for loop
Slices of tuples
If you want to change a tuple, you need to re-copy the tuple name
The inclusion of tuples
To modify the contents of a list within a tuple
But the elements in the tuple cannot be changed, the contents of the elements can be changed
Dictionary
Hash
Check whether the variable
Variable cannot be used as a dictionary key if the hash is immutable as a number
Lists and dictionaries are mutable, not as key
The dictionary is unordered and has no index
The value of the dictionary
[1] is key and not index
Remove Key from dictionary
Remove the value of the dictionary
The cycle of a dictionary
Default Fetch Dictionary Key
Take key and value
Remove the value of the list
You can use this iteration to iterate through the list tuples, but you can't use the dictionary with range.
User name password for dictionary application
Another way to store
Python Learning notes Section III