Python 名称';sp&x27;定义不明确
我正在与numpy和spotipy一起检索我的播放列表。这是我有问题的代码Python 名称';sp&x27;定义不明确,python,python-3.x,numpy,machine-learning,spotipy,Python,Python 3.x,Numpy,Machine Learning,Spotipy,我正在与numpy和spotipy一起检索我的播放列表。这是我有问题的代码 def get_features_for_playlist(uri): playlist_id = uri.split(':')[2] results = sp.user_playlist(username, playlist_id) 它不断地给我错误 NameError: name 'sp' is not defined 谁能帮帮我吗。我已尝试搜索spottily文档,但它显示的代码与我在此处使用的
def get_features_for_playlist(uri):
playlist_id = uri.split(':')[2]
results = sp.user_playlist(username, playlist_id)
它不断地给我错误
NameError: name 'sp' is not defined
谁能帮帮我吗。我已尝试搜索spottily文档,但它显示的代码与我在此处使用的代码相同。根据错误,尝试添加:
from spotipy import Spotify as sp
作为代码的第一行,它看起来不像您导入了
spotipy
基于错误,请尝试添加:
from spotipy import Spotify as sp
作为代码的第一行,它看起来不像是您导入的spotipy
请确保编写:
sp = spotipy.Spotify()
确保你写下:
sp = spotipy.Spotify()
您是否导入了spotipy?请查看
sp
是如何在中定义的,例如,.Yes。我进口了斯波蒂。但现在显示:模块“spotipy”没有“user\u playlist”属性嗨,我发现了错误!我必须把sp=spotipy.Spotify()放入。它现在正在工作。您导入了spotipy吗?请看一下sp
是如何在中定义的,例如,.Yes。我进口了斯波蒂。但现在显示:模块“spotipy”没有“user\u playlist”属性嗨,我发现了错误!我必须把sp=spotipy.Spotify()放入。它现在正在工作模块“spotipy”没有属性“user_playlist”@AryajPandey Try now模块“spotipy”没有属性“user_playlist”@AryajPandey Try now