您的位置:首页 > 其它

TypeError: string indices must be integers, not str

2014-07-01 16:46 525 查看
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'] 。这样的错误
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: