python - 为什么我在 python 中得到一个带有 spotipy 的 attributeError?
问题描述
我按照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'
解决方案
推荐阅读
- macos - 如何修复 OSX Catalina 上的终端“源”命令
- java - HTML 输入字段不接受格式正确的十进制
- javascript - 为什么 attrTween 中未定义“d”?
- python - 带有自定义数据的 QML PieSeries 自定义模型
- c# - 无法让 Lamar (IOC) 解决 .NET Core 3.1 中的 API 控制器依赖关系
- python - 在 Python 中将数据保存在 XML 文件中
- wordpress - 在 WordPress 中添加 Twitter 卡片
- asynchronous - 异步任务中止时会发生什么?
- svg - 为什么我得到的 SVG 路径与 chrome 的结果截然不同?
- postgresql - Postgresql 表不显示在 Navicat 数据库 ui 管理器上