Isprintable() Method Of Str Class In Python

Method Name:

isprintable

Method Signature:

isprintable()

Parameters:

None

Return Value:

True – if no non-printable characters found. False otherwise.

 

Overview:

  • The method isprintable()checks whether all the characters of a Python string literal are printable. If all the characters it returns True.
  • If one or more characters of a string literal is non-printable  isprintable()returns False.
  • For empty strings the method returns True.

 

Example:

# Example Python program that tests whether

# a string literal is composed fully of printable characters

testString      = "Token\u001C";

printability    = testString.isprintable();

print("The string has all of its characters printable:");

print(printability);

 

 

Output:

The string has all of its characters printable:

False


Copyright 2020 © pythontic.com