Custom function syntax:
Python custom function uses def keyword, the general format is as follows:
def 函数名(参数): ... 函数体 ...
The definition of function mainly has the following points :
1. def: keyword representing the function
2. Function name: the name of the function. The function will be called based on the function name in the future
3. Function body: in the function Perform a series of logical calculations, such as: sending emails, calculating the maximum number in [11,22,38,888,2], etc...
4. Parameters: Provide data for the function body
5. Return value: After the function is executed, data can be returned to the caller.
Code example:
# 定义函数 def test_a(): print('hello world') # 调用函数 test_a()
Recommended tutorial: python tutorial
The above is the detailed content of How to customize functions in python. For more information, please follow other related articles on the PHP Chinese website!