Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python 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, \t tab feed, \s space feed and \r carriage return etc.

Syntax

string.isprintable()

Parameters

No parameter is required.

Return Value

Returns True if all characters of the specified string are printable, else returns False.

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())

The output of the above code will be:

True

False

❮ Python String Methods