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 * >>> ...
随机推荐
- Android GIS开发系列-- 入门季(10) MapView快速定位到Geometry
我们知道某个Geometry的坐标,但不知道具体的位置,该如何使地图快速定位呢?这时需要用到MapView.setExtent方法,来看下这个方法的介绍:Zooms the map to the gi ...
- Windows Server2008 R2 设置NAT 让Hyper-V连接Internet
1.添加虚拟网卡,设置为内部,并且固定IP地址192.168.1.1 255.255.255.0 此为内网网卡 2.添加服务器角色:DHCP服务器,DNS服务器,网络策略和访问服务 3."网 ...
- 带头尾和动画的下拉刷新RecyclerView
项目地址:https://github.com/shichaohui/AnimRefreshRecyclerView 项目中包括一个demo(普通Androidproject)和Android Lib ...
- Mariadb 事务
事务 事务具有ACID特性:原子性(A,atomicity).一致性(C,consistency).隔离性(I,isolation).持久性(D,durabulity). 1.原子性:事务内的所有操作 ...
- android 特殊符号开头的联系人归并至“#”下
在PeopleActivity界面.联系人的显示位置是由其display name的第一个字符决定的. 数字开头的联系人会显示在"#"这个header下. 中英文联系人会显示在&q ...
- hdu 5253 连接的管道(kruskal)(2015年百度之星程序设计大赛 - 初赛(2))
连接的管道 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- 2016/1/17 private public protected 权限练习
package caipiao; private class Test0117 { private String title; public String actor; protected Strin ...
- linux内核对块设备的使用
1 partition table 这里的分析以经典的MBR为例. 在MBR里面有partition table,每一项对应一个逻辑的块设备,partion table中的每一项是16个字节. 第一个 ...
- URL 字段简析
URL:统一资源定位符:URL是uri的一个子集,另外一个子集是URN. URL语法:(来自HTTP权威指南中文版P29) 组件 描述 默认值 方案 访问服务器以获取资源时要使用哪种协议 无 用户 某 ...
- centos7 tengine2.1.2 编译安装 防火墙设置
安装 pcre 和 openssl yum -y install pcre pcre-devel yum -y install openssl openssl-devel wget http://te ...