Copyright © tutorialspoint.com
This method returns the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).
str.ljust(width[, fillchar]) |
Here is the detail of parameters:
width: string length in total after padding.
fillchar: filler character, default is a space
It returns the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).
#!/usr/bin/python str = "this is string example....wow!!!"; print str.ljust(50, '0'); |
This will produce following result:
this is string example....wow!!!000000000000000000 |
Copyright © tutorialspoint.com