Home > Article > Backend Development > What does rjust mean in python?
Python rjust() returns a new string with the original string right-aligned and padded with spaces to length width. If the specified length is less than the length of the string, the original string is returned.
rjust() method syntax:
str.rjust(width[, fillchar])
Parameters
width -- Specifies the total length of the string after filling the specified characters. fillchar -- The characters to be filled, the default is a space.
Related recommendations: "Python Video Tutorial"
Return value
Return an original string right-aligned and use A new string padded with spaces to length width. If the specified length is less than the length of the string, the original string is returned
Example
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 results of the above examples are as follows:
000000000000000000this is string example....wow!!!
The above is the detailed content of What does rjust mean in python?. For more information, please follow other related articles on the PHP Chinese website!