def 函数名([参数表]): "文档字符串" 函数体
函数体需要缩进
例:打印字符串
def printStr(x) '''print the string''' print(x)函数的返回
return 表达式1,表达式2,...,表达式n
如果返回多个值,则这些值构成一个元组
例:计算两个数之和
def sum(x,y): '''计算参数的和''' return x+y
如果不需要返回任何值,则不用return语句,或return None
函数调用函数名([参数表])
实参:函数调用时括号里的实际参数,在函数调用时分配实际的内存空间
》如果有多个实参,逗号隔开
》如果没有实参,用函数名()形式调用
def printStr(x)
'''print the string'''
print(x)
>>>printStr("hello,world!")
hello,world
main函数
链接:Python中的main函数
lambda函数lambda函数又称匿名函数,可以让用户快速地定义单行函数
Python 之 lambda 函数完整详解 & 巧妙运用_Nick.Peng's Blogs-CSDN博客
》lamba函数+map()函数,把函数逐一映射到列表的每一个元素得到结果
》lamba函数+sort()函数,对列表中元素遍历进行计算,并对值或键进行排序
》lamba函数+filter()函数,筛选列表符合条件的元素



