Python中判断Nonetype的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dongdong9223/article/details/85339387

转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/85339387
本文出自【我是干勾鱼的博客

Ingredients:

python中出现:

TypeError: ‘NoneType’ object is not subscriptable

的错误时说明需要进行判断,而对 ‘NoneType’ 进行判断时直接使用‘is None’即可,如下:

if text is None:
    print('test is ' + None)
else:
    print('test is not ' + None)

参考:

Python中的Nonetype类型怎么判断

猜你喜欢

转载自blog.csdn.net/dongdong9223/article/details/85339387