Python Colorama module

Source: Internet
Author: User

Colorama is a python-specific module for outputting color text in the console and command line, and can be used across platforms.

1. Installing the Colorama module

1 pip install colorama

  

Available Format constants:

123 Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.Style: DIM, NORMAL, BRIGHT, RESET_ALL

  

Cross-platform printing color text can use the constant abbreviation ANSI escape sequence of colored light:

123456 fromcolorama importFore,Back,Styleprint(Fore.RED +"some red text")print(Back.GREEN +"and with a green background")print(Style.DIM +"and in dim text")print(Style.RESET_ALL)print("back to normal now!!")

  


init keyword parameter:
Init () accepts some * * Kwargs override default behavior

1 init(autoreset =False):

  


If you find yourself repeatedly sending reset sequences at the end of the turn off color changes every print, then init (Autoreset = True) will be automated
Example:

1234 fromcolorama import init,Foreinit(autoreset=True)print (Fore.RED + "welcome to python !!")print("automatically back to default color again")

Python Colorama module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.