str.center(width, padstr=' ') รข new_str
Instance Public methods
Centers str
in width
. If width
is
greater than the length of str
, returns a new String of length
width
with str
centered and padded with
padstr
; otherwise, returns str
.
"hello".center(4) #=> "hello" "hello".center(20) #=> " hello " "hello".center(20, '123') #=> "1231231hello12312312"
Please login to continue.