8 examples of 'python print color' in Python

Every line of 'python print color' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
41def _print_color(color, string, *args):
42 """Prints string in color to stdout
43 """
44 print(colorize(string % args, color))
163def pyPrint(stuff):
164 stuff = 'PY:' + stuff + "\n"
165 sys.stdout.write(stuff)
13def color_print(msg, status=0):
14 # status 三个设定值, 0 为一般输出, 1 为错误输出, 2 为成功输出
15 green = False
16
17 def succeed_or_failed_print():
18 check_tty = subprocess.Popen('tty', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19 check_tty_return_str = check_tty.stdout.read().decode("utf-8")[0:-1]
20 if 'Windows' in platform.system() and check_tty_return_str in ('/dev/cons0', ''):
21 clr = Color()
22 if green:
23 clr.print_green_text(msg)
24 else:
25 clr.print_red_text(msg)
26 else:
27 if green:
28 cprint(msg, 'green', attrs=['bold'])
29 else:
30 cprint(msg, 'red', attrs=['bold'])
31
32 if status == 0:
33 print(msg)
34 elif status == 1:
35 # 为 1 错误输出
36 green = False
37 succeed_or_failed_print()
38 else:
39 # 为 2 成功输出
40 green = True
41 succeed_or_failed_print()
31@staticmethod
32def green():
33 if not TextColor._NoColor:
34 print(Fore.GREEN,end='')
7def colorprint(verbosity, text):
8 if verbosity == "fatal":
9 print(Style.BRIGHT + Fore.RED + text + Style.RESET_ALL)
10 if verbosity == "warn":
11 print(Fore.YELLOW + text + Style.RESET_ALL)
12 if verbosity == "info":
13 print(Style.DIM + Fore.WHITE + text + Style.RESET_ALL)
14 if verbosity == "success":
15 print(Style.BRIGHT + Fore.GREEN + text + Style.RESET_ALL)
10def printc(color, vmsg):
11 print (color + vmsg + ENDC, end='')
12 sys.stdout.flush()
108@staticmethod
109def blue(*args, **kwargs):
110 print(Colors.fg.blue, *args, **kwargs)
111 print(Colors.reset, end="")
20def cprint(str, *args, **kwargs):
21 print str

Related snippets