两种方式打印彩色文本的区别

I want to print a colored text in console. So I use this code provided here:

class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'

我对使用此类的方式感到犹豫。据说:

要使用这样的代码,您可以执行以下操作      打印(bcolors。警告+“警告:没有有效的frommets剩余。   继续吗?” + bcolors.ENDC)      或者,使用Python3.6 +:      print(f“ {bcolors.WARNING}警告:没有有效的frommets剩余。   继续吗?{bcolors.ENDC}“)

I'm using python 3.7, but both of these codes work for me, so I wanted to know how the usage is different based on Python version and what is that f mentioned Python3.6+ part?

评论