How to Use String isprintable() Method in PythonPython Basics


The isprintable() determines if all characters in the string are printable characters.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

# All characters can be printed out
print('ABCDtabcd'.isprintable())

# n can not be printed out, thus return false
print('ABCDnabcd'.isprintable())

Output:

True
False

Syntax

str.isprintable()

Parameters

The method doesn’t take any parameters.

Return Value

It returns True or False, depending upon whether a string is printable.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us