Python outputs a color string and python outputs a string.

Source: Internet
Author: User

Python outputs a color string and python outputs a string.

Output A color string to display the highlighted part. Tested, it is feasible in pycharm and not feasible in windows command line. Unknown cause.

Method:

Format: "\ 033 [display mode; foreground color; background color m: a color-changing string \ 033 [display mode m" Example: "\ 033 [1; 31; 47 m color changing string \ 033 [0 m "<1-highlight 31 foreground color red 47 background color black -- Color Changing string -- 0-cancel color setting> description: foreground color background color --------------------------------------- 30 40 black 31 41 red 32 42 green 33 43 colors 34 44 blue 35 45 purple red 36 46 Blue 37 47 white display meaning ------------------------- 0 terminal default settings cancel color settings) 1 Highlight 4 Use underline 5 Flash 7 reverse white display 8 invisible

Test:

Print ("\ 033 [1; 31; 40 m string to be colored \ 033 [0 m ")

Result:

 

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.