前提・実現したいこと
ここに質問の内容を詳しく書いてください。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
リスト構造とデータセットのことがわからず困っています
AIDEMYさんのブログで乗せられていたコードです
artist_items = spotapi_out['artists']['items'][0]
IndexError: list index out of range
エラーメッセージ artist_items = spotapi_out['artists']['items'][0] IndexError: list index out of range ### 該当のソースコード ```python ソースコード ```import spotipy import json import pandas as pd import matplotlib.pyplot as plt import networkx as nx from community import community_louvain from spotipy.oauth2 import SpotifyClientCredentials client_id = 'xxxxxxxxxxxxxxx' client_secret = 'XXXXXXXXXX' client_credentials_manager = spotipy.oauth2.SpotifyClientCredentials(client_id, cli\ ent_secret) spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager) # アーティスト情報を格納するDataFrameを定義 artist_df = pd.DataFrame(columns=['artist_name','artist_ID','genre','popularity','r\ elated_artist_names']) name = 'Dj Bucher' spotapi_out = spotify.search(q='artist:' + name, type='artist') artist_items = spotapi_out['artists']['items'][0] artist_id = artist_items['id'] artid_list = [artist_id] artname_related_list = [] spotapi_out_related = spotify.artist_related_artists(artist_id) ### 試したこと わからなすぎるので助けてください ### 補足情報(FW/ツールのバージョンなど) Macでライブラリはほぼ最新のものが入っていると思います リスト構造とデータセットがわからないので教えてください
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/12 10:47
2018/09/12 10:50
2018/09/12 10:53
2018/09/12 10:56