How Can I Make Text Bold In Python?
Solution 1:
You might want to try ANSI escape sequences if your platform allows it.
Crossposting from related - and possible duplicate - SO questions: 12
Before you proceed, please read the warnings in the above links to make sure your operating system and Python version will allow you to properly render this.
You can define a class containing all of the ANSI escape sequences you need.
classstyle:
BOLD = '\033[1m'END = '\033[0m'
Then print
them via concatenated class calls:
print style.BOLD + 'This is my text string.' + style.END
If you don't want to go through the hassle of creating an entire class just to get bold text, you can obviously concatenate them directly instead. However, if your code is open-source and not for personal use, make sure you tell other potential readers what this does!
print'\033[1m' + 'This is my text string.' + '\033[0m'
Does this answer your question?
Edit: JYelton beat me to it. I'm such a slow typer...
Post a Comment for "How Can I Make Text Bold In Python?"