如题所述
python中None代表一个特殊的空值,即为一个空对象,没有任何的值。
一般用于assert,判断,函数无返回时的默认,具体如下:
assert断言:
mylist = ['a', 'b', 'c']>>> assert len(mylist) is not None # 用assert判断列表不为空,正确无返回>>> assert len(mylist) is None # 用assert判断列表为空
if...else...
3.如果函数无return,则默认返回None