0
点赞
收藏
分享

微信扫一扫

Python TypeError: ‘NoneType‘ object is not subscriptable


Python TypeError: ‘NoneType’ object is not subscriptable

分析

现有一变量 ​​li​​ ,list 类型,通过索引去获取获取value


Python TypeError: ‘NoneType‘ object is not subscriptable_python

是可以取到value,但是如果 ​​li = None​​ ,再通过索引获取value就会报错


Python TypeError: ‘NoneType‘ object is not subscriptable_后端_02

同理,如果变量是dict类型也会出现一样的报错

Python TypeError: ‘NoneType‘ object is not subscriptable_后端_03

总结

对一个值为None的变量,进行索引取值或通过key取值,都会报 ​​'NoneType' object is not subscriptable​​ 错。



举报

相关推荐

0 条评论