首页 > 解决方案 > 嗨,我刚开始 AttributeError:'list' 对象没有属性 'get'

问题描述

数据 = data.get('aggs')[0].get('subreddit')

df = pandas.DataFrame.from_records(data)[0:10]

标签: python

解决方案


您需要导入代码中使用的包(或模块):

import requests
import pandas # this is missing from the article you referred to

另外,如果你还没有安装 Plotly,你会想要使用 pip install plotly或来安装conda install plotly

有几篇关于导入和 Python 模块/包的好文章,例如https://www.devdungeon.com/content/python-import-syspath-and-pythonpath-tutorialHow to import other Python files?


推荐阅读