utils.py 文件源码

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

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

        :params users: API['result']['userprofiles']
        :return: a User object.
        """

        if len(users) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Name'])
            for i, user in enumerate(users, 1):
                table.add_row([i, user['nickname']])
            click.echo(table)

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

        user_id = users[select_i-1]['userId']
        user_name = users[select_i-1]['nickname']
        user = User(user_id, user_name)
        return user
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号