Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 35

Python Exercise Example 35

Python 100 Examples Python 100 Examples

**Question:** Set text color.

**Analysis:** None.

Example

#!/usr/bin/python

-- coding: UTF-8 --

class

bcolors

:

HEADER

=

'

\0

33[95m

'

OKBLUE

=

'

\0

33[94m

'

OKGREEN

=

'

\0

33[92m

'

WARNING

=

'

\0

33[93m

'

FAIL

=

'

\0

33[91m

'

ENDC

=

'

\0

33[0m

'

BOLD

=

'

\0

33[1m

'

UNDERLINE

=

'

\0

33[4m

'

print

(

bcolors

.

WARNING

"

Warning color and font?

"

bcolors

.

ENDC

)

The output of the above example is:


警告的颜色字体?    # 浅黄色

Python 100 Examples Python 100 Examples