colorprinter.py 文件源码

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

项目:Harbor-CLI 作者: srishanbhattarai 项目源码 文件源码
def colorprint(text_color, bail_result=False):
    '''
    Colorprint text into the console. Call it as a curried function.

    greenPrinter = colorprinter('GREEN')
    greenPrinter('this will be green')

    OR:

    colorprint('GREEN')('this will be green')
    '''
    def printer(text):
        ''' This actually does the printing part. Allows for reusable color printers. '''
        color = Fore.GREEN if text_color == 'GREEN' else Fore.RED
        if not bail_result:
            print(color + text)
            print(Style.RESET_ALL)
        else:
            return color + text

    return printer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号