Python's color display

Source: Internet
Author: User

We know that at the command line, Python's output has the same string color as the normal character.

If we want to emphasize certain characters, we can make use of the part of the code that will be emphasized to become a color.

The Linux Terminal command can display a color that cannot be displayed under the Windows CMD Terminal display

The writing format, and the related instructions are as follows

Format: \033[display mode; background color m (all content) format: \033[display; foreground color m emphasize content \033[0m (some content) Description: foreground            background color           ---------------------- -----------------,              black, red, green, yellow,              Blue                45 The           significance-------------------------0 The                terminal default setting 1                highlight 4, purple red                use underscore 5                blinking 7                anti-white display 8 invisible                \033[0m  #采用终端默认设置


1 Print("\033[1;32m This is a test \033[0m")#1 Highlight 32 foreground green2 Print("\033[1;42m This is a test \033[0m")#42 background Color green3 Print("\033[1;31;40m; This is a test \n123456")#1 Highlight 31 Red 41 black background4 Print("\033[4;31m This is a test \033[0m\n123")#a section of content 4 underline

Python's color display

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: 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.