解决TypeError: 'NoneType' object is not subscriptable
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");
解决TypeError: 'NoneType' object is not subscriptable的更多相关文章
- TypeError: 'NoneType' object is not subscriptable
运行,显示TypeError: 'NoneType' object is not subscriptable错误信息,原因是变量使用了系统内置的关键字list 重新定义下这个变量就好了
- python类型错误:'NoneType' object is not subscriptable
TypeError: 'NoneType' object is not subscriptable --> 原因:变量使用了系统内置的关键字list 解决:重新定义下这个变量
- openpyxl使用sheet.rows或sheet.columns报TypeError: 'generator' object is not subscriptable解决方式
解决方案: 因为新版本的openpyxl使用rows或者columns返回一个生成器所以可以使用List来解决报错问题 >>> sheet.columns[0] Traceback ...
- python: "TypeError: 'type' object is not subscriptable"
目前stackoverflow找到两种情况的解决办法: 1.TypeError: 'type' object is not subscriptable when indexing in to a di ...
- Debug 路漫漫-11:Python: TypeError: 'generator' object is not subscriptable
调试程序,出现以下错误: Python: TypeError: 'generator' object is not subscriptable “在Python中,这种一边循环一边计算的机制,称为生成 ...
- python报错:TypeError: 'int' object is not subscriptable
检查一遍报错的所在行,此报错一般是在整数上加了下标: 比如: a = 4 c=a[2] 报错:line 2, in <module> c=a[2] TypeError: 'i ...
- python TypeError: 'NoneType' object is not iterable
list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > ...
- openpyxl中遇到TypeError: 'generator' object is not subscriptable的问题和解决方案
今天在搭建驱动数据框架用到了一个叫 openpyxl的包用来解析excel数据 随后就出现了TypeError: 'generator' object is not subscriptable的bug ...
- TypeError: 'generator' object is not subscriptable
TypeError: 'generator' object is not subscriptable 生成器对象不可以带下标 def get_row(self,row_no): if not isin ...
- python"TypeError: 'NoneType' object is not iterable"错误解析
尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...
随机推荐
- 形式化验证工具TLA+:程序员视角的入门之道
简介: 女娲是飞天分布式系统中提供分布式协同的基础服务,支撑着阿里云的计算.网络.存储等几乎所有云产品.在女娲分布式协同服务中,一致性引擎是核心基础模块,支持了Paxos,Raft,EPaxos等多 ...
- [FAQ] Cannot use object of type MongoInt64 as array
此类情况出现在 需要使用字符串/数组,实际却使用了对象. 解决方式是调试数据,对数据类型进行转换即可. MongoInt64 对象提供 __toString 方法,那么可以强转成 64 位 integ ...
- Rancher管理K8s集群(14)
一.Rancher介绍 1.1 Rancher简介 Rancher 是一个开源的企业级多集群 Kubernetes 管理平台,实现了 Kubernetes 集群在混合云+本地 数据中心的集中部署与管理 ...
- 001_Cadence软件的安装与介绍
001_Cadence软件的安装与介绍 软件版本16.6,软件下载:搜索PCB联盟; 安装步骤: 1) 把5个分卷的压缩包解压到同一文件夹; 2) 双击Setup.exe开始安装,先安装Lic ...
- Solution Set - 数学相关
CF645F Link&Submission. 利用 \(\sum\limits_{d|n}\varphi(\frac{n}{d})=n\),只要对每个数 \(x\),求出 \(cnt_x\) ...
- 我的 Kafka 旅程 - 概念 · 特点 · 组成 · 模式 · 应用
系列目录 我的 Kafka 旅程 - 概念 · 特点 · 组成 · 模式 · 应用 我的 Kafka 旅程 - Linux下的安装 · 基础命令 · 集群 我的 Kafka 旅程 - Producer ...
- 特工17Agent17汉化版游戏破解金币方法修改破解金币的增加方法
又是一个renpy游戏,昨晚搞了半个小时搞定的,其实这个游戏要赚钱也不难,就是点点点就可以了,但是我觉得还是挺费劲的,因为好多道具都很贵,攒钱又不怎么容易,花钱的地方还挺多的,所以干脆不如直接破解了算 ...
- Sermant在异地多活场景下的实践
本文分享自华为云社区<Sermant在异地多活场景下的实践>,作者:华为云开源. Sermant社区在1.3.0和1.4.0版本相继推出了消息队列禁止消费插件和数据库禁写插件,分别用于解决 ...
- 使用可视化工具redis-desktop-manager管理查询缓存。
AnotherRedisDesktopManager https://gitee.com/qishibo/AnotherRedisDesktopManager/releases 下载windows版本 ...
- ansible(19)--ansible的playbook
目录 1. playbook简介 2. playbook编写规范 2.1 YAML语法规范 2.2 YAML语法要素 2.3 Playbook核心元素 2.4 Playbook的基础组件 3 Play ...