特殊字面量------None
- 表示:空值、无值、无意义
- 类型:NoneType
- 布尔值:False
- 不能参与数学运算,也不能与字符串拼接
- 不给函数设置返回值,函数会默认返回None
python
msg=None# 不暗示具体类型,更中立、更开放
返回值
函数执行完毕后,会把执行结果交给调用者,这个执行结果就是返回值。
return关键字:return会结束函数执行,并把**return后的值,**作为函数的返回值。
python
def add(n1, n2):
print(f'我收到了:{n1}、{n2},二者相加是{n1 + n2}')
return n1 + n2
result = add(100, 200)
print(result)