Home  >  Article  >  Backend Development  >  What does rjust mean in python?

What does rjust mean in python?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-27 09:12:4112830browse

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.

What does rjust mean in python?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn