成功解决TypeError: tuple indices must be integers or slices, not str
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                成功解决TypeError: tuple indices must be integers or slices, not str
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                成功解決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格式即可!
?
?
?
?
?
總結
以上是生活随笔為你收集整理的成功解决TypeError: tuple indices must be integers or slices, not str的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Py之MT:Multithreaded的
- 下一篇: 成功解决如何去掉输出字典,前边的dict
