您当前的位置: 首页 > 
  • 0浏览

    0关注

    2393博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

成功解决TypeError: tuple indices must be integers or slices, not str

一个处女座的程序猿 发布时间:2018-07-12 23:05:10 ,浏览量:0

成功解决TypeError: tuple indices must be integers or slices, not str

 

目录

解决问题

解决思路

解决方法

 

 

 

解决问题

TypeError: tuple indices must be integers or slices, not str

for row in cur:  #每行规范输出
     print("name=%s, AGE=%d" % (row['name'], row['age']))

 

 

解决思路

类型错误:元组索引必须是整数或切片,而不是字符串。

 

 

 

解决方法

可知cur此时是个tuple或者其他空列表等,而不是dict,只需要将其转为dict格式即可!

 

 

 

 

 

关注
打赏
1664196048
查看更多评论
立即登录/注册

微信扫码登录

0.2607s