Time:
the time_format = "% D%% Y-X-M-%" --- Set time format
time_current = time.strftime (time_format) ---- time format using
higher-order function:
Variable parameters can point function, the function can be receive variables, a function that can receive another function as a parameter, this function is called to order function
, for example:
ABS (-10) 10 --- --- built-in functions, negative to positive stresses
def add (a, B, D)
return F (a) + F (B)
the Add (. 3, -6, ABS)
anonymous functions:
anonymous function is no explicit specified function
, for example: calc = lambda n: n ** n
function definition:
DEF funtion ():
.........
parameters:
arguments: actually present in memory
parameter: actually exists, but after running function will disappear
positional parameters: def test (x, y) --- characteristics: parameter correspondence with
a keyword parameters: test (y = 1, x = 2) ---- features: parameter independent of the order (as long as it must be changed to match)
The default parameters: def test (y, x = 1, y = 2) ---- Features: delivery time can be overridden
Note: The
keyword parameter is not written in the front position parameters, or will be error
when the parameters passed only can correspond to a location, can not have multiple positions at a time to pass a parameter value
loaded manner not change before dictionary keyword parameters, time parameters can be accepted but the
parameter group:
(. 1) Test DEF (X, * args)
DEF test (* args) ---- features: you can accept multiple arguments and put inside a tuple,
for example:
by value: test (1,23,4,5)
transmission list: test (* [1,2 , 34,5])
(2) Test DEF (** kwargs) ---- features: the N-th keyword stored parameters into a dictionary
for example:
transfer value: test (name = 'chenming' , age = 9) --- ways to write keywords
transfer dictionary: test (** { 'name' : 'chen', 'age': 8})
references:
kwargs [ 'name'] --- display value
return value return:
The return value can be a tuple: example: return 1, 'hello', [ 'wo', 'ni'], { 'name': 'chen'}
return value can be a value of None
Return Value can be a boject
local variable :
that is, in a certain range which affect certain parameters, such as the function declaration of
local variables are global variables can not be changed, but only strings and integers
global variables:
the impact of global variables, global
recursion:
the concept: use time continue to enter when the inner layer is not going to return results to the total after the call is completed, the results returned from the inside out, maximum 998 recursive
characteristics
must have a clear end variables,
recursive efficiency is not high, too many levels of recursion can cause a stack overflow
each time deeper into the recursive problem size should be reduced compared to the previous recursive
functional programming:
functional programming function of this term does not refer to the computer's function (actually Subroutine), but learning index the function, i.e., the argument map. That value is only a function of the value determined in the function parameters, independent of other state. For example sqrt (x) function calculates the square root of x, as long as the same x, whenever called, calling times, the value is constant
, for example:
var Subtract Result = (Multiply (the Add (1,2),. 3), 4);
3-python automated self
Guess you like
Origin www.cnblogs.com/chenming-1998/p/11717296.html
Recommended
Ranking