首页 > 其他 > 详细

TypeError: string indices must be integers, not str

时间:2014-07-03 00:35:43      阅读:1298      评论: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,布布扣,bubuko.com

TypeError: string indices must be integers, not str

原文:http://www.cnblogs.com/hanframe/p/3818677.html

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