qq_43059948 2019-01-23 18:45 采纳率: 100%
浏览 13442
已采纳

Python 3.7 AttributeError: 'str' object has no attribute 'items' 报错怎么解决

图片说明
求大佬帮忙看下这样的报错怎么解决

  • 写回答

3条回答 默认 最新

  • Watch_dou 2019-01-24 12:51
    关注

    items()方法是字典的用法,对于str是没有该用法的,从报错的地方看,说明你的header是string类型,而非字典类型,找到对应的位置,看看你想得到什么结果:

    >>>
    >>> k={'as':1,'fds':2}
    >>> k.items()
    dict_items([('as', 1), ('fds', 2)])
    >>>
    >>> j='qwfguqf'
    >>> j.items()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'str' object has no attribute 'items'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)