Python musicbrainzngs:从艺术家搜索中获取ID

Python musicbrainzngs:从艺术家搜索中获取ID,python,dictionary,musicbrainz,Python,Dictionary,Musicbrainz,目前正在学习python以原谅我,但我正在使用此musicbrainzngs API从用户输入中获取艺术家姓名的ID。然后,它应该采取的ID和名单5随机歌曲从艺术家的问题。现在我正试图找出从相关艺术家那里获取ID的方法,这样就可以在单独的搜索中使用它,从该艺术家那里返回5首歌曲 文档API: 代码如下所示: from urllib.request import Request, urlopen import musicbrainzngs import sys musicbrainzngs.set

目前正在学习python以原谅我,但我正在使用此musicbrainzngs API从用户输入中获取艺术家姓名的ID。然后,它应该采取的ID和名单5随机歌曲从艺术家的问题。现在我正试图找出从相关艺术家那里获取ID的方法,这样就可以在单独的搜索中使用它,从该艺术家那里返回5首歌曲

文档API:

代码如下所示:

from urllib.request import Request, urlopen
import musicbrainzngs
import sys
musicbrainzngs.set_useragent("LyricsWordCount", "1.0", "azizn03",)
#musicbrainzngs.set_hostname("musicbrainz.org", use_https=False)

artist = input("Enter Artist Name ")

result = musicbrainzngs.search_artists(artist="" + artist, type="group",
                                   country="GB")
for artist in result['artist-list']:
    print("{name}: {id}".format(name=artist["name"], id=artist['id']))
结果:

Enter Artist Name coldplay
Coldplay: cc197bad-dc9c-440d-a5b5-d52ba2e14234
Viva La Coldplay: 62c54a75-265f-4e13-ad0a-0fb001559a2e
The Beatles: b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d
The Rolling Stones: b071f9fa-14b0-4217-8e97-eb41da73f598
Pink Floyd: 83d91898-7763-47d7-b03b-b92132375c47
George Frideric Handel: 27870d47-bb98-42d1-bf2b-c7e972e6befc
使用以下命令:


id\u of_first\u artist=result['artist-list'][0]['id']

您的问题/问题是什么?您的代码有什么问题?问题是我想从第一个结果中获取id,即第一个coldplay结果之后的字符串,并将其存储在变量中。@myke@DYZ@myke这是它的输出,它的输出是什么?