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'] 。这样的错误

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2021-11-22
  • 2022-02-05
  • 2021-08-06
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案