首页 > 其他 > 详细

TypeError: string indices must be integers, not str

时间:2017-09-04 21:50:47      阅读:862      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/li134655/p/7475894.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!