【发布时间】:2019-12-01 16:47:57
【问题描述】:
我在 python 中使用scholarly 模块来搜索关键字。我正在返回一个生成器对象,如下所示:
import pandas as pd
import numpy as np
import scholarly
search_query = scholarly.search_keyword('Python')
print(next(search_query))
{'_filled': False,
'affiliation': 'Juelich Center for Neutron Science',
'citedby': 75900,
'email': '@fz-juelich.de',
'id': 'zWxqzzAAAAAJ',
'interests': ['Physics', 'C++', 'Python'],
'name': 'Gennady Pospelov',
'url_picture': 'https://scholar.google.com/citations?view_op=medium_photo&user=zWxqzzAAAAAJ'}
我想访问 'citedby' 元素,但是当我尝试执行 next(search_query)['citedby'] 时,它返回 TypeError: 'Author' object is not subscriptable。
我的问题是如何访问生成器对象中的元素?以及如何将该对象转换为 Pandas 数据框?
【问题讨论】:
标签: python generator google-scholar