Home > Backend Development > Python Tutorial > What does rjust mean in python?

What does rjust mean in python?

爱喝马黛茶的安东尼
Release: 2019-06-27 09:12:41
Original
12860 people have browsed it

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');
Copy after login

The output results of the above examples are as follows:

000000000000000000this is string example....wow!!!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template