Share your repls and programming experiences

← Back to all posts
AnsiPrint - Coloured text made easy.
ChezCoder (1607)

Installation

ENTER THIS IN THE CONSOLE:

import os
os.system("pip install AnsiPrint")

USE IT LIKE THIS IN THE CODE:

import AnsiPrint

CHECK IT OUT ON PYPI: AnsiPrint

Usage

Note: For people who don't like reading the docs, this package is just colorama and termcolor squished into two functions.

UsageParamsReturn Value
ansiprint()str: msg, str: color-name/ansi, str: endstr: msg
ansi()str: color-name/ansistr: ansi
clear()None: NoneNone: None

Examples


ansiprint()

Code:

ansiprint("This is red!","red")
ansiprint("This is blue!","blue")
ansiprint("This is white and ends with \"!\"",end="!")

Result:


ansi()

Code:

print(ansi("red") + "This is red!" + ansi("reset"))
print(ansi("blue") + "This is blue!" + ansi("reset"))
print(ansi(34) + "This is the ansi \"34\"!" + ansi("reset")) # ansi codes are in the ansi chart below

Result:


clear()

Code:

print("This message isn't seen because the console is cleared after!")
clear()
print("This message is seen because it is after the console is cleared!")

Result:


Ansi Chart

This was made for the community; use it in any project you want, no credit needed :)

@Warhawk947 visit count: 3
Comments
hotnewtop
[deleted]

Hmm, I remember writing a good ~100 line version in JavaScript and C++. Nice work!

[deleted]

wow!

NoelB33 (352)

I found it in the package explorer

ChezCoder (1607)

@NoelBryan thanking the repl gods...

Warhawk947 (524)

@NoelBryan @ChezCoder hate to burst your bubble, but the repl package search acts as a search function of pypi itself, so any package you put on pypi will be put on the repl package search.

ChezCoder (1607)

@NoelBryan i felt so happy for like half an hour XD

BobNeo (39)

Oooooooooooooo how do you do the code block on mobile @ChezCoder

ChezCoder (1607)

@BobNeo you use the back tick: `Hello!` -> Hello!

BobNeo (39)

@ChezCoder Also can I use this in a project im making?

ChezCoder (1607)

@BobNeo of course! This was meant for the community to use! Use it in any project your heart desires :)

nN34398Ff (109)

HOW DO YOU MAKE TEXT BIG@ChezCoder

nN34398Ff (109)

(like this)
[maybe]@nN34398Ff
{likely not}
~hmm~

nN34398Ff (109)

\awefo\@nN34398Ff

nN34398Ff (109)

@nN34398Ff this is slanted so what is big

CodingCactus (4336)

@nN34398Ff
just put a # in front of the line (and a space between the words)
e.g.
# hello
|
V

hello

AmazingMech2418 (1103)

@nN34398Ff It's Markdown. Click the link that says "Style your post with Markdown" for the documentation.

AmazingMech2418 (1103)

@ChezCoder I don't know. I just said that Repl.it comments use Markdown...

CodingCactus (4336)

@nN34398Ff it needs to be at the start of the line

E.g.
# hello