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
评论列表
文章目录