Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def print_slow(s, speed=.04, color="", bold=False, newline=True):
- color_codes = {"Black": 30," Red": 31, "Green": 32, "Yellow": 33, "Blue": 34, "Purple": 35, "Cyan": 36, "White": 37}
- color = "\33[{};{};49m".format(
- 1 if bold else 0,
- color_codes.get(color, color_codes["Black"])
- )
- for c in s:
- sys.stdout.write(color+c)
- sys.stdout.flush()
- time.sleep(speed)
- if newline:
- print("\33[0m")
- else:
- sys.stdout.write("\33[0m")
- sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement