Python – La méthode String isprintable()
La méthode isprintable() renvoie True si tous les caractères sont affichables, sinon renvoie False. Un exemple de caractère non affichable peut être le retour et le saut de ligne.
Syntaxe:
string.isprintable()
Paramètres:
La méthode isprintable() ne prend aucun paramètre.
Valeur de retour:
La méthode isprintable() renvoie:
- True : Si la chaîne est vide ou si tous les caractères de la chaîne sont affichables.
- False : Si la chaîne contient au moins un caractère non affichable.
Exemple 1:
str = "Welcome to WayToLearnX!" x = str.isprintable() print(x)
Sortie:
True
Exemple 2:
str = "Welcome to \n WayToLearnX!" x = str.isprintable() print(x)
Sortie:
False