我用Spotipy搜索歌曲标题来检索曲目。我不知道如何获取查询的状态代码,以便使我的应用程序更安全。有什么想法吗?在
下面是一个代码片段:
sp = spotipy.Spotify()
results = sp.search(q=title, type='track')
#Want to check if status code of the sp.search command is 200 or something else.
#How?
trackListing = results['tracks']['items']
看起来内部spotipyapi并没有返回状态代码。但是,它会抛出一个SpotifyException来表示HTTP错误。将代码放在try/except块中并捕获
SpotifyException
以获得相同的结果。在相关问题 更多 >
编程相关推荐