Latest web development tutorials

Metoda Python3 zfill ()

Python3 ciąg Python3 ciąg


opis

Python zfill () zwraca ciąg znaków, który określa długość oryginalnego napisu wyrównane do prawej strony, zero-wyściełane przodu.

gramatyka

zfill () Składnia metody:

str.zfill(width)

parametry

  • Szerokość - określa długość łańcucha. Oryginalny ciąg tuż uzasadnione, zero-wyściełane przodu.

Wartość zwracana

Zwraca długość łańcucha.

Przykłady

Poniższy przykład pokazuje zfill () do użycia:

#!/usr/bin/python3

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

Przykłady powyższych wyników wyjściowych, są następujące:

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

Python3 ciąg Python3 ciąg