【发布时间】:2018-02-13 09:42:05
【问题描述】:
使用 Spotify 的 API 按艺术家搜索的正确 Python 语法是什么?也许我错过了一些明显的东西(盯着这个太久了)
根据文档,标题“授权”和参数“q”和“类型”是必需的。
https://developer.spotify.com/web-api/search-item/
我尝试过的:
artist_name = 'Linkin%20Park'
artist_info = requests.get('https://api.spotify.com/v1/search', header = {'access_token': access_token}, q = artist_name, type = 'artist')
ERROR: TypeError: requests() got an unexpected keyword argument 'q'
然后我想,也许参数必须作为列表发送?:
artist_info = requests.get('https://api.spotify.com/v1/search', header = {'access_token': access_token}, query = list(q = artist_name, type = 'artist'))
但是:
ERROR: TypeError: list() takes at most 1 argument (2 given)
【问题讨论】: