python functions in use

First, parameter passing

def op_file(file_name,content=None)

1, will pass parameters (file_name)

2, the default value of the parameter (content = None) if not pass, pass directly to the body of the function None, function call does not pass does not matter content

Second, variable

1, global variables

Variables defined outside the function is a global variable

Execution order

First local variables, local variables can not be found in the case laid down a global variable

2, modify global variables

a. in the local want to modify global variables, you need to use the global statement to be changed is a global variable

3, the function can call other functions

 

Third, the constant (constant variables do not change it is eg: PI, defined using capital letters)

Guess you like

Origin www.cnblogs.com/fandonghua/p/11586589.html