Advertisement
Guest User

Untitled

a guest
Dec 1st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. def print_slow(s, speed=.04, color="", bold=False, newline=True):
  2. color_codes = {"Black": 30," Red": 31, "Green": 32, "Yellow": 33, "Blue": 34, "Purple": 35, "Cyan": 36, "White": 37}
  3. color = "\33[{};{};49m".format(
  4. 1 if bold else 0,
  5. color_codes.get(color, color_codes["Black"])
  6. )
  7. for c in s:
  8. sys.stdout.write(color+c)
  9. sys.stdout.flush()
  10. time.sleep(speed)
  11. if newline:
  12. print("\33[0m")
  13. else:
  14. sys.stdout.write("\33[0m")
  15. sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement