Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Python String ljust() Method
Description:
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).
Syntax:
str.ljust(width[, fillchar])
|
Parameters:
Here is the detail of parameters:
Return Value:
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).
Example:
#!/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
|
|
|
|