utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:netease-dl 作者: ziwenxie 项目源码 文件源码
def select_one_artist(artists):
        """Display the artists returned by search api.

        :params artists: API['result']['artists']
        :return: a Artist object.
        """

        if len(artists) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Artist Name'])
            for i, artist in enumerate(artists, 1):
                table.add_row([i, artist['name']])
            click.echo(table)

            select_i = click.prompt('Select one artist', type=int, default=1)
            while select_i < 1 or select_i > len(artists):
                select_i = click.prompt('Error Select! Select Again', type=int)

        artist_id = artists[select_i-1]['id']
        artist_name = artists[select_i-1]['name']
        artist = Artist(artist_id, artist_name)
        return artist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号