Python-pycharm Console output with color

Source: Internet
Author: User

In the process of Python development, you will often encounter the need to print various kinds of information. The huge amount of information piled up in the console will result in information being mixed together, reducing the readability of important information.     At this time, if the important information can be added to the font color, then it will be more convenient for users to read. Of course, the display of the console is limited, and can not be as cool as the previous paragraph, only to do some simple settings. But from the point of view of readability, it has been much better. The writing format, and related instructions are as follows: Copy code copy Code # Format: Set color start: \033[display mode, foreground color, background m# description: foreground color background color----------------------------------                -----30 40 Black 31 41 Red 32 42 Green 33              43 Yellow 34 44 Blue 35 45 Magenta 36 46                Cyan Blue 37 47 white display means meaning-------------------------0 terminal default settings 1 Highlighting 4 using underscore 5 blinking 7 anti-white display 8 invisible #例子: \033[1;31;40m &lt ;! --1-highlighting 31-front color Red 40-background color black-->\033[0m <!--with terminal default settings, that is, remove color settings--Copy Code copy code example 1: Copy code copy Code print (' \033[0;32;40m Welcome to make Use the student selection system \033[0m ') try:num = Int (input (' Enter digital selection function: ') except Exception as E:print (' \033[31m Sorry! The inside of your inputTolerance Error ~\033[0m ') Copy code copy code run Result: Example 2:print (' \033[0;36m firecrackers in one year in addition, ') print (' Spring Breeze send warm into tusujiu. Print (' Thousand Doors million Tong Tong Day, ') print (' Always replace the new peach with the old symbol. \033[0m ') operation result:

  

Python-pycharm Console output with color

Related Article

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.