如何解决为什么我在 python 中得到带有 spipy 的属性错误?
我按照 https://www.section.io/engineering-education/spotify-python-part-1/ 中对 spotipy 的介绍进行操作,但由于某种原因,我收到了 AttributeError。有人经历过类似的吗?
这是我在 main.py 中的代码:
import spotipy
from spotipy.oauth2 import SpotifyOAuth
import cred
scope = "user-read-recently-played"
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=cred.client_id,client_secret= cred.client_secret,redirect_uri=cred.redirect_url,scope=scope))
results = sp.current_user_recently_played()
for idx,item in enumerate(results['items']):
track = item['track']
print(idx,track['artists'][0]['name']," – ",track['name'])
这是我来自 cred.py 的代码(我不确定我是否使用 redirect_url 做对了):
client_ID = 'ed8de3e9b4d64e63a7e7251b5e5d7059'
client_SECRET = 'c5e0dcd1d01e48ffac80b22bc1fbe929'
redirect_url = 'http://localhost:8888/callback'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。