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的更多相关文章

  1. python报错 TypeError: string indices must be integers

    所以在读取字典的时候,最好先判断类型,然后再查看它是否已经有这样的属性: type(mydict) == type({})             #检查不是字典 如果是字典,再看看有没有这样的属性: ...

  2. TypeError: list indices must be integers or slices, not str

    错误如下: TypeError: list indices must be integers or slices, not str 错误代码块: aa是一组list套dict数据 函数insert接收 ...

  3. 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 ...

  4. 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 ...

  5. “TypeError: list indices must be integers or slices, not str”有关报错解决方案

  6. 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] # 检出人脸区域后 ...

  7. socket编程: TypeError: must be bytes or buffer, not str

    先看一段代码 #!/usr/bin/env python3 from socket import * serverName = "10.10.10.132" serverPort ...

  8. TCP客户端和服务器间传输数据遇到的TypeError: a bytes-like object is required, not 'str'问题

    使用python实现python核心编程3第472页和474页的TCP时间戳服务器和客户端服务器间数据传输编程时遇到TypeError: a bytes-like object is required ...

  9. moviepy执行TextClip.search方法时报错TypeError: a bytes-like object is required, not str

    ☞ ░ 前往老猿Python博文目录 ░ 执行TextClip.search方法时,报错: >>> from moviepy.editor import * >>> ...

随机推荐

  1. 洛谷 P2033 Chessboard Dance

    P2033 Chessboard Dance 题目描述 在棋盘上跳舞是件有意思的事情.现在给你一张国际象棋棋盘和棋盘上的一些子以及你的初始位置和方向.求按一定操作后,棋盘的状态. 操作有四种,描述如下 ...

  2. 使用Hexo搭建博客

    好长时间没在博客园写东西了,自己搭了一套博客,把自己的一些积累分享给大家,欢迎指正! 博客地址:http://www.baiguangnan.com 使用Hexo搭建自己的博客,可以参考这里:http ...

  3. hadoop的linux配置

    一.新建hadoop组跟用户(password:hadoop) [root@localhost home]# groupadd hadoop [root@localhost home]# userad ...

  4. STL之关联容器的映射底层

    STL的关联容器有set, map, multiset, multimap.用于实现它们的底层容器有划入标准的rb_tree和待增加标准的hashtable. 底层容器rb_tree为上层容器提供了一 ...

  5. web网站架构演变过程

    我们以javaweb为例,来搭建一个简单的电商系统,看看这个系统可以如何一步步演变.   该系统具备的功能:   用户模块:用户注册和管理 商品模块:商品展示和管理 交易模块:创建交易和管理 阶段一. ...

  6. HDU 1269 迷宫城堡 最大强连通图题解

    寻找一个迷宫是否是仅仅有一个最大强连通图. 使用Tarjan算法去求解,经典算法.必需要学习好,要自己创造出来是十分困难的了. 參考资料:https://www.byvoid.com/blog/scc ...

  7. 第二天,初步slide第一版和家的照片墙

    今天基本完成任务, 1. 写了昨天的总结, 2. 完成slides的第一个完整版. 3. 家里布置了照片墙. 4. 其他的 未完成: 1. 框架搭建:Creasy没来. 领导力:为公司利益早起,任务说 ...

  8. [git push] rejecteded 问题的解决方法

    错误信息: hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart ...

  9. JavaScript基础 -- js常用内置方法和对象

    JS中常用的内置函数如下: 1.eval(str):计算表达式的结果. 2.parseInt(str,n):将符串转换成整数数字形式(可指定几进制). 3.parseFloat(str):将字符串转换 ...

  10. bootrap 手风琴Collapse源码分析

    /* ======================================================================== * Bootstrap: collapse.js ...