In this section we will learn what String isprintable() method is and how to use it in Python.
What is String isprintable() Method in Python?
The Python string isprintable() method is used to see if the entire characters of a string value is printable.
For example, if the target string has a line-feed or carriage-return or a newline (these are examples of non-printable characters), then that string value has a character that cannot be printed.
Python String isprintable() Method Syntax:
string.isprintable()
String isprintable() Method Parameter
The method does not take an argument.
String isprintable() Method Return Value
The return value of this method is of type boolean.
The value True will return if the entire characters of the target string are printable. Otherwise, if even one character of the target string value is not printable, then the value False will return instead.
Example: using python string isprintable() method
s1= "Hello you" s2 = "Hello \n World" print(s1.isprintable()) print(s2.isprintable())
Output:
True False