Guest User

termcolor

a guest
May 7th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. import termcolor
  2. from termcolor import colored, cprint
  3.  
  4. print(termcolor.COLORS) # все цвета для шрифтов
  5. print(termcolor.HIGHLIGHTS, '\n') # все цвета фонов
  6.  
  7. '''Голубой текст на белом фоне'''
  8. text = colored('Hello, World!', 'blue', 'on_white')
  9. print(text)
  10.  
  11. '''Серый текст на желтом фоне'''
  12. text = colored('Hello, World!', 'yellow', 'on_grey', attrs=['reverse'])
  13. print(text) #атрибут reverse меняет местами цвет фона и цвет текста
  14.  
  15. '''Функция cprint() сразу же распечатывает полученный текст'''
  16. cprint('Hello, People!', 'green', attrs=['bold']) # bold - шрифт жирнее и ярче
  17.  
  18. '''Красный текст на светло-пурпурном фоне'''
  19. print_red_on_magenta = lambda x: cprint(x, 'red', 'on_magenta', attrs=['blink'])
  20. print_red_on_magenta('Hello, Universe!') # blink - делает фон более ярким
  21.  
  22. '''Подчеркнутый серый текст'''
  23. cprint("Attention!", 'grey', attrs=['underline']) # underline - подчеркивает текст
Advertisement
Add Comment
Please, Sign In to add comment