TypeError:必须是str,而不是使用nytimesapi获取数据的Python中的字节

2024-09-28 03:17:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python3.6中使用nytimesarticle包进行抓取。每当我试图寻找时

TypeError: must be str, not bytes.

我正在运行以下代码

from nytimesarticle import articleAPI
api = articleAPI('apikey')
articles = api.search(q="Obama", 
                      fq={"headline": "Obama", 
                          "source": ["Reuters", 
                                     "AP", 
                                     "The New York Times"]}, 
                      begin_date="20161001", # this can also be an int
                      facet_field=["source", "day_of_week"], 
                      facet_filter=True)

得到以下错误

^{pr2}$

Tags: 代码fromimportapisourcebytesnotbe

热门问题