求大佬帮忙看下这样的报错怎么解决
Python 3.7 AttributeError: 'str' object has no attribute 'items' 报错怎么解决
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
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'
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 6无用