Null string, empty list bool type is False
Inside the JSON is double quotes, and the outside is single quotes. Convert a string to a format corresponding to its contents
Content:
Simplified function definition, lambda
function definition:
Method One:
def func (ARG):
Return arg+1
Method Two:
Func = lambda Arg:arg + 1
Lambda Features:
1, for the simple logic
2. Auto return
Built-in functions:
First, the Map method
Iterate through the sequence, manipulate each element in the sequence, and finally get a new sequence
Second, the filter method
Filter, only if the value is true, you can, otherwise filter out
Cases:
Li = [11,22,33,44,55]
Print (Filter (lambda a:a > 33,li))
Results: [44, 55]
Third, reduce
For all elements within a sequence, there is an initial value that accumulates on top of this initial value.
Cases:
Li = [11,22,33,44,55]
Print reduce (lambda a1,a2:a1+a2,li,1000)
Results: 1165
Map: All element operations
Filter: Gets the specified element action collection
Reduce: additive operation
Yield generator:
Remember the last action, and the next time you execute it, continue
Return life cycle is over
For example:
def func (ARG):
Seed = 0
While True:
Seed = seed + 1
If seed > ARG:
Return directly ends the life cycle of the function
Else
Yield seed temporarily freezes the life cycle of a function
For I in Func (10):
Print (i)
Python Basic content Four