python中处理json中遇到的错误(2020年2月25日17:44:42)更新中…
一、AttributeError: ‘list’ object has no attribute ‘get’
这里的主要问题在这里,就是“hotComments”下级是列表,列表无法直接get,应该替换为
content1 = text_json.get("hotComments").get('content')
替换为:
content1 = text_json.get("hotComments")[0].get('content') #获取列表中第一个字典里边的的'content'
或者:
for i in content1:
i.get('content')