How to Use the just ust () method in Python
This article describes how to use the just ust () method in Python. It is the basic knowledge of getting started with Python. For more information, see
Returns the right-side length and width of a string. Fill is done by using the specified fillchar (space by default ). If the width is less than len (s), the original string is returned.
Syntax
The syntax of the just ust () method is as follows:
?
1 |
Str. Fill ust (width [, fillchar]) |
Parameters
Width -- this is the total length after the string is filled.
Fillchar -- this is a fill character. The default value is space.
Return Value
This method returns the right-side length and width of a string. Fill is done by using the specified fillchar (space by default ). If the width is less than len (s), the original string is returned.
Example
The following example shows how to use the just ust () method.
?
1 2 3 4 5 |
#! /Usr/bin/python Str = "this is string example... wow !!! "; Print str. Must ust (50, '0 '); |
When we run the above program, it will produce the following results:
?
1 2 3 4 5 6 7 |
000000000000000000 this is string example... wow !!! Str1 = "this is string example... wow !!! "; Str2 = "is "; Print str1.rindex (str2 ); Print str1.index (str2 ); |
When we run the above program, it will produce the following results:
?