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

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条)

报告相同问题?