How do you change the font in Python?
How do you change the font in Python? Would be pretty cool to learn this.
Coder100
You can't change the font, but you can change the colors.
Example:
print('\033[1mBold text\033[0m normal text')
Using ANSI escape codes. Wikipedia docs
Hopes this helps!
gibbsfreenergy
What does that code do? @Coder100
Coder100
so \033[
is the escape code and m
just means the end of the escape code. The number in between is the special number that is desired. (look at the Wikipedia page to see all) @JosephSanthosh
gibbsfreenergy
but when I run it just shows 'Bold text normal text' @Coder100
Coder100
and is the bold text bold? @JosephSanthosh
wesleyBoi
I can't seem to get the blink to work:
user = input("\033[5m" + 'Create a username:' + "\033[0m")
HahaYes
can't you use matplotlib for python?
Unfortunately, you can not change the font family of text in python. But, you can change the color of the text or add markdown to the text. Hope this answers your question! Upvote or choose as the correct answer if so.
@adl212 thx, but is there any other way I can decorate the text even more besides colors?
@JosephSanthosh You can use bold, underline, and etc.
do u know what or where the codes are? @adl212
@JosephSanthosh The ANSI color codes are
Just add them to your print function and it will change the text!
how do i write it inside a print() [email protected]
@JosephSanthosh You would do something like
print("\033[1m" + "This is bold text!" + "\033[0m")
Hope this helps!never mind I found out. [email protected]
there's more... @adl212
@Coder100 Ok, go ahead and tell us!
alright, there's also rgb support:
and 8bit (256 colors):
@adl212
there are 256 [email protected]
@Coder100 Ok, great! I didn't know of these!
:) glad to introduce ya @adl212
thanks guys @Coder100 @adl212
np :) @JosephSanthosh
@JosephSanthosh No problem!