python - ValueError:无法将国家/类别参数与来源参数混合

标签 python python-3.x python-module valueerror

我第一次使用 Python 使用 API,在执行此操作时出现以下错误:

ValueError: cannot mix country/category param with sources param.

我应该怎么做才能解决这个错误?

这是代码:

import config
from newsapi import NewsApiClient

newsapi = NewsApiClient(api_key=config.api_key)

top_headlines = newsapi.get_top_headlines(q='Neuralink',sources='the-verge',category='technology',language='en',country='us')```

最佳答案

根据官方“NewsAPI”{https://newsapi.org/docs/endpoints/top-headlines} top-headlines 文档, “国家”和“类别”不能与“来源”参数同时使用。

关于python - ValueError:无法将国家/类别参数与来源参数混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68544525/

相关文章:

python - 如何在 ubuntu 上安装 python 模块 sys、os 和 getopt?

python - 在 Cygwin 上安装 Python 3.0

python - 如何在python中替换特定单词后的下一个单词

python - pytest:获取 AttributeError: 'CaptureFixture' 对象没有属性 'readouterror' 捕获标准输出

python - 使用 PySide 将按字母顺序排列的项目添加到 QComboBox

Python: "ModuleNotFoundError",但是安装了模块?

python - 导入错误: Using the `Trainer` with `PyTorch` requires `accelerate`

Python Swagger 问题

python-3.x - 如何在 Gunicorn 启动其主进程之前触发函数

Python:是否可以只从 sys.path 中的文件夹中获取特定模块