Python 相当于带有用户名和 api 令牌的 CURL

Python equivalent of CURL with username and api token

我想将以下 curl 命令写入 python 代码。以下是从 URL.

请求一些数据的命令

: 替换为用户名
: 替换为令牌密钥

curl -u <user_name>/token:<api_token> <URL>

我们可以使用请求模块:

response = requests.get(<URL>, auth = (f'{<user_name>}/token', <api_token>))