string indices must be integers
翻译一下就是:字符串的下标一定要是整数。
比如
a = 'abcde'
print(a['0'])
#这就出错了,对吧 #这才是对的
print(a[0])
第二个就是因为请求url的response(res)是个json数据,所以需要json.loads(),才能把json格式转为python识别的格式。
itemList = json.loads(res.text)
还有就是手滑导致的错误
把切片的<:>写成了<,>
string indices must be integers相关推荐
- python3 错误string indices must be integers 的解决方法
这个错误意思是字符串的下标一定要是整数 出这种错误有多种可能,最形象直接的就是: a = '[abc]' print(a['0']) 有点pyhton基础的都知道下标怎么能是字符串'0',必须是整数0 ...
- Python错误:TypeError: string indices must be integers
在项目遇到一个错误 : TypeError: string indices must be integers 由于是返回的接口数据,所以一时也分辨不出是哪里的错,然后我就还原了这样的场景: unico ...
- 解决TypeError: string indices must be integers, not str
遇到问题 ExtendValue = {"area": "1","info": "{\"year\": 201 ...
- TypeError: string indices must be integers
1.错误描述 >>> print(st[-1,-6]); Traceback (most recent call last):File "<pyshell#13> ...
- python之解析 yaml配置文件时TypeError: string indices must be integers
#定义一个SuperLogin登录函数,传递3个形参数 def SuperLogin(lANIP,username, password):driver = webdriver.Chrome()driv ...
- python string indices must be_Python解析json时提示“string indices must be integers”问题解决方法...
本文实例讲述了Python解析json时提示"string indices must be integers"问题解决方法.分享给大家供大家参考,具体如下: import json ...
- Python 错误:TypeError String Indices Must be Integers 【已解决】
Python 错误:TypeError String Indices Must be Integers [已解决] 如果你尝试使用字符串值,而不是整数值来访问字典或可迭代对象的值,那么你将收到以下错误 ...
- python string indices must be_python报错string indices must be integers,怎么解决?
展开全部 python报错string indices must be integers解决如下: 在.py文件中写的data={"a":"123"," ...
- string indices must be integers错误原因
string indices must be integers:字符串索引必须是整数 一.使用字符串为索引 a = [1, 2, 3, 4] print(a['0']) '0'为字符串,0才是整形.这 ...
- python报错 TypeError: string indices must be integers
所以在读取字典的时候,最好先判断类型,然后再查看它是否已经有这样的属性: type(mydict) == type({}) #检查不是字典 如果是字典,再看看有没有这样的属性: ...
最新文章
- robolectric android studio,Android Studio + Robolectric + AndroidAnnotations 根本框架
- 动态规划 —— 线性 DP —— 最大和问题
- Github 教程 -- 使用指南
- 天涯明月刀服务器位置都在哪里,天涯明月刀手游好友服务器怎么查看 怎么看好友在哪个区?[多图]...
- hp/博科光纤交换机配置小记
- DllMain 用法
- 遇见未来 | 对话叶毓睿:人类文明运行在软件之上(下篇)
- 机电一体化综合实训考核装置
- 【乱七八糟的笔记】——前缀树
- lpfs存储服务器怎样维护,ipfs云节点存储服务器
- 一个菜鸟实习生的月总结
- 组合模式实例与解析 实例一:水果盘
- 一个计算机有几个cpu,为什么电脑都只有一个CPU
- 和Sun一起开源(武林外传游戏外挂Java源代码) - 论坛版
- CSS @page 规则 设置打印页面框的尺寸,方向和页边距,用于打印预览和从浏览器打印Web文档
- 你的脸正在被偷走,你却对此无能为力
- 2019暑期多校补题情况 牛客
- 2022.4.18-4.24 AI行业周刊(第94期):AI行业破局
- 怎么把pdf转换成word转换器
- 人脸识别 tracking.js学习