Latest web development tutorials

méthode python3 de zfill ()

string python3 string python3


description

Python zfill () retourne une chaîne qui spécifie la longueur de la chaîne d'origine justifié à droite, avant zéro rembourrée.

grammaire

zfill () syntaxe de la méthode:

str.zfill(width)

Paramètres

  • largeur - Indique la longueur de la chaîne. La chaîne d'origine justifié à droite, avant zéro rembourrée.

Valeur de retour

Renvoie la longueur de chaîne.

Exemples

L'exemple suivant montre zfill () fonction à utiliser:

#!/usr/bin/python3

str = "this is string example from w3big....wow!!!"
print ("str.zfill : ",str.zfill(40))
print ("str.zfill : ",str.zfill(50))

Des exemples des résultats de sortie ci-dessus sont les suivantes:

str.zfill :  this is string example from w3big....wow!!!
str.zfill :  000000this is string example from w3big....wow!!!

string python3 string python3