
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
isprintable() in Python and its application
In this article, we will learn about isprintable() in Python and its application.
Is printable() is a built-in method used for the purpose of string handling. The isprintable() methods return “True” when all characters present in the string are of type printable or the string is empty, Otherwise, It returns a boolean value of “False”.
Arguments − It doesn’t take any argument when called
List of printable characters include digits, letter, special symbols & spaces.
Let’s look at this illustration to check that whether the characters of string are printable or not.
Example
# checking for printable characters st= 'Tutorialspoint' print(st.isprintable()) # checking if \n is a printable character st= 'Tutorials \n point' print(st.isprintable()) # checking if space is a printable character string = '' print( string.isprintable())
Output
True False True
Example
# checking for printable characters st= 'Tutorials$$point&&' print(st.isprintable()) # checking if \t is a printable character st= 'Tutorials \t point' print(st.isprintable()) # checking if underscore is a printable character string = '_' print( string.isprintable())
Output
True False True
Application
To rectify the error of printing error at runtime we can handle this exception and replace all non-printable characters with the desired symbol to print onto the console
This is also useful when we have to format the output in a specific manner so as to remove the unwanted things like escape sequences
Conclusion
In this article, we learnt about the isprintable() function and its application in Python 3.x. Or earlier.
- Related Articles
- divmod() in Python and its application
- C++ bitset and its application ?
- Pascals Law and Its Application
- Internet of Things (IoT) and its Application in Manufacturing
- Python Language advantages and application
- Birthday Reminder Application in Python
- What is hydrogenation? What is its industrial application?
- Get Application Version using Python
- A number and its triple in Python
- Ethics in Psychology: Meaning and Application
- How to open any file with its default application with PowerShell?
- Isupper() and Islower() and their application in C++
- Difference Between Applet and Application
- Res Judicata: Meaning and Application
- Maritime Law: Meaning and Application
