python - 嗨,我刚开始 AttributeError:'list' 对象没有属性 'get'
问题描述
数据 = data.get('aggs')[0].get('subreddit')
df = pandas.DataFrame.from_records(data)[0:10]
解决方案
您需要导入代码中使用的包(或模块):
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-tutorial或How to import other Python files?