To Underline Text In Python, the Unicode character
"\u0332", acts as an underline on the character that precedes it in a string. So, if you put any string after this Unicode, the text will be printed underlined in Python.
Underline Text In Python using
def underline(text): print("\u0332".join(text)) print("\u0332".join("How are you?")) underline("Hello reader!")
H̲e̲l̲l̲o̲ ̲r̲e̲a̲d̲e̲r̲! H̲o̲w̲ ̲a̲r̲e̲ ̲y̲o̲u̲?
You can try the ANSI escape sequences method as well to Underline Text In Python from this answer on StackOverflow.
class Format: end = '\033[0m' underline = '\033[4m' print(Format.underline + 'Your text here' + Format.end)
Your text here
We hope these examples will help you to learn how to print underlined text in Python.
Thank you for reading this article, click here to start learning Python in 2022.
- Gender Recognition by Voice using Python
- File Explorer in Python using Tkinter
- Drawing Application in Python Tkinter
- Top 32 Python Interview Questions For Experienced
- Top 10 Final Year Projects for Computer Science Students
- Diabetes prediction using Machine Learning
- Tkinter GUI Calendar in Python
- Library Management System Project in Java
- Bank Management System Project in Java
- CS Class 12th Python Projects
- Python Alarm Clock | Tkinter GUI App
- Top 10 Python Projects for Final year Students
- 10 Tkinter Projects for Beginners
- Python OOP Projects | Source code and example
- Generate QR Code in Python
- Make Minecraft in Python
- Data Science Projects for Final Year
- Movie Recommendation System: with Streamlit and Python-ML
- Machine Learning Projects for Final Year
- Tip Calculator using Python
- Inventory Management System Project in python
- Barcode and QR Code Reader Python
- Courier Management System project in Python
- Contact Management System Project in Python
- Python SQLite Tutorial
- Student Management System Project in Python
- 20 Python Projects for Resume
- Restaurant management system project in Python
- Employee Management System Project in Python
- Bank Management System Project in Python