年夜雪

关注

解决TypeError: 'NoneType' object is not subscriptable

年夜雪

关注

阅读 13

2024-10-30

1.捕获异常的方式

try:
  img_list = img_list["name"]
except:
  img_list = ""

2.对象进行判断

if img_list:
  img_list = img_list["name"]
else:
  img_list = ""  demo
 textJson = json.loads(res.text)   #转json对象
    if textJson:  ##整个对象都是空的
  print("this object is null");

相关推荐

乌龙茶3297

Python TypeError: ‘NoneType‘ object is not subscriptable

乌龙茶3297 168 0 0

陌岛

完美解决TypeError: ‘method‘ object is not subscriptable

陌岛 22 0 0

阎小妍

TypeError: ‘function‘ object is not subscriptable

阎小妍 111 0 0

unadlib

【Python报错】成功解决TypeError: ‘xxx’ object is not subscriptable

unadlib 25 0 0

狗啃月亮_Rachel

❌【Error】TypeError: ‘NoneType‘ object is not callable

狗啃月亮_Rachel 118 0 0

玉字璧

TypeError: ‘builtin_function_or_method‘ object is not subscriptable

玉字璧 143 0 0

陆公子521

python3 TypeError: 'map' object is not subscriptable

陆公子521 167 0 0

心存浪漫

python实战:报错:TypeError: ‘int‘ object is not subscriptable

心存浪漫 139 0 0

mm_tang

解决pyhton object is not subscriptable

mm_tang 54 0 0

千妈小语

python错误提示:TypeError: ‘builtin_function_or_method‘ object is not subscriptable

千妈小语 149 0 0

精彩评论(0)

0 0 举报