TypeError: tuple indices must be integers or slices, not str
not or be must Str TypeError tuple Integers
2023-09-27 14:27:32 时间
已解决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格式即可!
PS
有问题评论区留言即可
相关文章
- SQL SERVER 不支持多字段的IN 和 NOT IN
- 集成环信时遇到的问题file not found: libEaseMobClientSDK.a
- WPF binding not updating the view
- content is not supported outside 'script" or asp content' region
- Procedure or function 'pu_usr_User' expects parameter '@WhiteIp', which was not supplied.
- git删除本地和远程文件,解决 fatal: Not a git repository (or any of the parent directories): .git 问题
- Error: Could not find or load main class org.elasticsearch.tools.JavaVersionChecker
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
- 1092 To Buy or Not to Buy (20 分)【难度: 简单 / 知识点: 模拟】
- 微信小程序 - wx:key警告does not look like a valid key name?(wx:key=“{{index}}“ does not look like a valid )
- Unable to open socket file: target process not responding or HotSpot VM not loaded异常处理方法
- TNS-12557: TNS:protocol adapter not loadable TNS-12560: TNS:protocol adapter error
- Vue报错笔记(1)vue.esm.js?efeb:628 [Vue warn]: Property or method “handleClick“ is not defined on the...
- statsmodels.tsa.arima_model预测时报错TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'
- 1449 - The user specified as a definer ('test'@'%') does not exist
- This application failed to start because it could not find or load the Qt platform plugin "windows"
- 浅析CentOS安装docker及遇到的问题:Failed to start docker.service: Unit not found或docker: command not found
- An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
- 今天犯的一个错误,导致method GET must not have a request body
- Not registered via @EnableConfigurationProperties or marked as Spring component
- Could not load file or assembly……
- PCRE does not support L, l, N{name}, U, or u...
- eclipse 报错:One or more constraints have not been satisfied.
- 1092 To Buy or Not to Buy