网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  TypeError: string indices must be integers, not str

TypeError: string indices must be integers, not str

分类: IT文章 • 2022-04-10 14:18:18

1. TypeError: string indices must be integers, not str

字符串类型取第index个字符的时候,应该传入int而不是str。如

view source 
 
print?
1 a='abcdef'
2 print a[0]
3 #而不是 print a['0']

更常见的情况是把一个string当成了字典在使用 :should_be_dict_but_string['id'] 。这样的错误

相关推荐

  • python报错 TypeError: string indices must be integers
  • 微信小程序登录 该死的官方文档TypeError: the JSON object must be str, not 'bytes'
  • Python: list indices must be integers or slices, not float问题
  • Version value must be a string; got a NilClass () (TypeError)
  • Python3 TypeError: initial_value must be str or None, not bytes
  • Python3 TypeError: initial_value must be str or None, not bytes
  • TypeError: must be string or buffer, not long
  • socket编程: TypeError: must be bytes or buffer, not str
  • requests+unittest接口自动化之报错:TypeError: list indices must be integers or slices, not str
  • python TypeError: must be str, not bytes错误
  • Python3中的hashlib模块
  • TypeError:'dict' object is not callable TypeError:'dict' object is not callable
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号