Advertisement
tjone270

quake colour text in python (new print function)

Apr 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import colorama
  2.  
  3. def qprint(*args, **kwargs):
  4.     colorama.init()
  5.     args = list(args)
  6.     qcodes = {0: colorama.Fore.BLACK, 1: colorama.Fore.RED, 2: colorama.Fore.GREEN, 3: colorama.Fore.YELLOW, 4: colorama.Fore.BLUE, 5: colorama.Fore.CYAN, 6: colorama.Fore.MAGENTA, 7: colorama.Fore.WHITE}
  7.     for index, arg in enumerate(args):
  8.         for code, colour in qcodes.items():
  9.             if "^{}".format(code) in arg:
  10.                 args[index] = args[index].replace("^{}".format(code), colour) + colorama.Style.RESET_ALL
  11.     print(*args, **kwargs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement