Latest web development tutorials

Metodo python3 zfill ()

stringa python3 stringa python3


descrizione

Python zfill () restituisce una stringa che specifica la lunghezza della stringa originale giustificato a destra, davanti a zero imbottita.

grammatica

zfill () metodo di sintassi:

str.zfill(width)

parametri

  • larghezza - Specifica la lunghezza della stringa. La stringa originale giustificato a destra, davanti a zero imbottita.

Valore di ritorno

Restituisce la lunghezza della stringa.

Esempi

L'esempio seguente mostra zfill () per l'uso:

#!/usr/bin/python3

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

Esempi dei risultati di output di cui sopra sono i seguenti:

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

stringa python3 stringa python3