Python - String isprintable() Method


Advertisements

The string isprintable() method is used to check whether all characters of the string are printable or not. It returns true when all characters of the string are printable, else returns false. Few of the non-printable characters are - \n line feed, \ttab feed, \sspace feed and \r carriage return etc.

Syntax


string.isprintable()

Example:

In the below example, isprintable() method to used to check whether all characters of the string are printable or not.

MyString = "Hello World!"
print(MyString.isprintable())

MyString = "Hello\nWorld"
print(MyString.isprintable())

Output

True

False

String Methods
Advertisements