Change shell print color in python 3.3.2

后端 未结 4 1807
太阳男子
太阳男子 2021-01-15 02:20

Is there any way to change shell print color in python 3.3.2 in Linux and Windows shell? I\'ve read all other topics but none of them working with this version or I should i

4条回答
  •  再見小時候
    2021-01-15 02:57

    Colors in python

    Print text nicely or style text using python

    
    # the ANSI codes are stored in variables, making them easier to use
    black = "\033[0;30m"
    red = "\033[0;31m"
    green = "\033[0;32m"
    yellow = "\033[0;33m"
    blue = "\033[0;34m"
    magenta = "\033[0;35m"
    cyan = "\033[0;36m"
    white = "\033[0;37m"
    bright_black = "\033[0;90m"
    bright_red = "\033[0;91m"
    bright_green = "\033[0;92m"
    bright_yellow = "\033[0;93m"
    bright_blue = "\033[0;94m"
    bright_magenta = "\033[0;95m"
    bright_cyan = "\033[0;96m"
    bright_white = "\033[0;97m"
    
    print(black + "Hello world")
    print(red + "Hello world")
    print(green + "Hello world")
    print(blue + "Hello world")
    print(yellow + "Hello world")
    print(magenta + "Hello world")
    print(cyan + "Hello world")
    print(bright_black + "Hello world")
    print(bright_red + "Hello world")
    print(bright_green + "Hello world")
    print(bright_blue + "Hello world")
    print(bright_cyan + "Hello world")
    print(bright_magenta + "Hello world")
    print(bright_yellow + "Hello world")
    

    output :

    View : Colored output

提交回复
热议问题