Python rjust() method

Python rjust() method
Python rjust() returns a new string with the original string right-aligned and padded with spaces to the length width. If the specified length is less than the length of the string, the original string is returned.
Syntax of rjust() method
str.rjust(width[,fillchar])
Parameter
width-specify the total length of the string after filling the specified characters
fillchar-filled characters, the default is a space.
Return value
Return a new string with the original string right-aligned and padded with spaces to the length width. If the specified length is less than the length of the string, the original string instance will be returned. The
following example shows how to use the rjust() function:
#! /usr/bin/python
str-"this is string example…wow!!!";
print str.rjust(50,'0); The
output of the above example is as follows:
000080000000008000 this is string example…wow!!!

Guess you like

Origin blog.csdn.net/m0_53052839/article/details/110508305