TypeError: string indices must be integers, not str
1. TypeError: string indices must be integers, not str
字符串类型取第index个字符的时候,应该传入int而不是str。如
1 |
a='abcdef' |
2 |
print a[0] |
3 |
#而不是 print a['0'] |
更常见的情况是把一个string当成了字典在使用 :should_be_dict_but_string['id'] 。这样的错误
TypeError: string indices must be integers, not str的更多相关文章
- python报错 TypeError: string indices must be integers
所以在读取字典的时候,最好先判断类型,然后再查看它是否已经有这样的属性: type(mydict) == type({}) #检查不是字典 如果是字典,再看看有没有这样的属性: ...
- TypeError: list indices must be integers or slices, not str
错误如下: TypeError: list indices must be integers or slices, not str 错误代码块: aa是一组list套dict数据 函数insert接收 ...
- for遍历用例数据时,报错:TypeError: list indices must be integers, not dict,'int' object is not iterable解决方法
一:报错:TypeError: list indices must be integers, not dict for i in range(0,len(test_data)): suite.addT ...
- faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method
https://blog.csdn.net/qq_27637315/article/details/78849756 https://blog.csdn.net/qq_21089969/article ...
- “TypeError: list indices must be integers or slices, not str”有关报错解决方案
- TypeError: slice indices must be integers or None or have an __index__ method
由于除法/自动产生的类型是浮点型,因此出现上述错误,修正方法为,将/更改为// roi_gray_lwpCV = gray_lwpCV[y:y + h // 2, x:x + w] # 检出人脸区域后 ...
- socket编程: TypeError: must be bytes or buffer, not str
先看一段代码 #!/usr/bin/env python3 from socket import * serverName = "10.10.10.132" serverPort ...
- TCP客户端和服务器间传输数据遇到的TypeError: a bytes-like object is required, not 'str'问题
使用python实现python核心编程3第472页和474页的TCP时间戳服务器和客户端服务器间数据传输编程时遇到TypeError: a bytes-like object is required ...
- moviepy执行TextClip.search方法时报错TypeError: a bytes-like object is required, not str
☞ ░ 前往老猿Python博文目录 ░ 执行TextClip.search方法时,报错: >>> from moviepy.editor import * >>> ...
随机推荐
- java生成xml
import java.io.File;import java.io.FileOutputStream;import java.text.SimpleDateFormat;import java.ut ...
- CentOS 7 es搭建测试
搭建本地yum repo pass 指定特定repo 安装,比如安装wget.(指定特定repo 是为了从最快的repo安装) yum --disablerepo=\* --enablerepo=os ...
- Mysql入门实战中
前面一章主要解说了mysql的入门学习.包括数据库,表的管理,以及对数据的增删改,本章主要介绍mysql最重要的语句select的使用方法.将select的大部分使用方法进行分别解说. 全部代码下载( ...
- Android之AssetManager使用
1. 获取AssetManager AssetManager assetManager = context.getAssets(); 2. 列出assets文件夹下全部文件 String[] file ...
- web 开发之js---js 实现网页中播放wav的一种方法(flash播放器)
http://blog.csdn.net/whumr1/article/details/6948160
- Cocos2d-x3.1下 Android,APK自己主动升级
项目要做Android的自己主动升级,对于我们之前做iOS的转Cocos开发做Android方面的功能..... 不正确说了.这里记录下我的实现过程. 原文地址:http://blog.csdn.ne ...
- my.os.ClickThisWindow.ClickThisPoint.py
my.os.ClickThisWindow.ClickThisPoint.py
- HDU1052Tian Ji -- The Horse Racing
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- YTU 2677: 韩信点兵
2677: 韩信点兵 时间限制: 1 Sec 内存限制: 128 MB 提交: 61 解决: 38 题目描述 刘邦问韩信:"你觉得我可以带兵多少?"韩信:"最多十万. ...
- YTU 2642: 填空题:类模板---求数组的最大值
2642: 填空题:类模板---求数组的最大值 时间限制: 1 Sec 内存限制: 128 MB 提交: 646 解决: 446 题目描述 类模板---求数组的最大值 找出一个数组中的元 ...