utils.py 文件源码

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

项目:papis 作者: alejandrogallo 项目源码 文件源码
def confirm(prompt, yes=True):
    """Confirm with user input

    :param prompt: Question or text that the user gets.
    :type  prompt: str
    :param yes: If yes should be the default.
    :type  yes: bool
    :returns: True if go ahead, False if stop
    :rtype:  bool

    """
    import prompt_toolkit
    result = prompt_toolkit.prompt(
        prompt + ' (%s): ' % ('Y/n' if yes else 'y/N')
    )
    if yes:
        return result not in ['N', 'n']
    else:
        return result not in ['Y', 'y']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号