YouTip LogoYouTip

Python3 String Zfill

# Python3.x Python3 zfill() Method [![Image 3: Python3 Strings](#) Python3 Strings](#) * * * ## Description The Python zfill() method returns a string padded with zeros to a specified width. The original string is right-aligned, and zeros are added to the front. ## Syntax The syntax for the zfill() method is: str.zfill(width) ## Parameters * width -- Specifies the desired length of the string. The original string is right-aligned, and zeros are added to the front. ## Return Value Returns a string of the specified length. ## Example The following example demonstrates the usage of the zfill() function: #!/usr/bin/python3 str = "this is string example from ....wow!!!"print ("str.zfill : ",str.zfill(40))print ("str.zfill : ",str.zfill(50)) The output of the above example is: str.zfill : this is string example from ....wow!!! str.zfill : 000000this is string example from ....wow!!! * * Python3 Strings](#)
← Java Arraylist GetJava Arraylist Clone β†’