Python‎ > ‎str‎ > ‎

str.ljust()


Definition
Return string left-justified in a Unicode string of length width. Padding is done using the specified fill character (default is a space).

Syntax
str.ljust(width[, fillchar]) -> str

Parameters
str=string
width=number
fillchar=string

Examples
The returns with:
 >>> "Python Lake".ljust(55, "P")
'Python LakePPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP'
>>>

str.center()
similar method:
The method str.center() returns with the filling the character in center provided.
 >>> "Python Research Centre".center(44,'o')
'oooooooooooPython Research Centreooooooooooo'
>>> "Python Research Centre".center(44,'p')
'pppppppppppPython Research Centreppppppppppp'
>>> "Python Research Centre".center(23,'a')
'aPython Research Centre'
>>> 


Comments