Python ljust () method
description
Python ljust () method returns a raw string left-justified, and padded with spaces to the new string specified length. If the length is less than the length of the original string of the original string is returned.
grammar
ljust () method syntax:
str.ljust(width[, fillchar])
parameter
- width - Specifies the length of the string.
- fillchar - fill characters, the default is spaces.
return value
Returns a string of former left-justified, and padded with spaces to the new string specified length. If the length is less than the length of the original string of the original string is returned.
Examples
The following example shows ljust () to use:
#!/usr/bin/python str = "this is string example....wow!!!"; print str.ljust(50, '0');
Examples of the above output results are as follows:
this is string example....wow!!!000000000000000000