NoneType

None是内置常量,是NoneType的唯一真值。None经常用于表示缺少值。

python中None的典型用法:

  • 定义函数时的默认参数占位符
>>> def func(x, y=None):
        pass
  • 如果函数没有返回值默认会返回None
>>> def func():
        pass
>>> res = func()
>>> print(res)
None     
posted @ 2022-08-19 17:44  python心蓝  阅读(223)  评论(0编辑  收藏  举报