Alignment of the string in the output:
S.ljust (width, [FillChar])
# output width characters, S left-aligned, and the gap filled with FillChar, default spaces.
S.rjust (width, [fillchar]) # right justified
S.center (width, [fillchar]) # aligned intermediate
S.zfill (width) # output width characters, and aligned on the right, make up the shortage with 0
>>>s = 'this is a string.' >>>s.ljust(50,"*") 'this is a string.*********************************' >>>s.rjust(50, "*") '*********************************this is a string.' >>>s.center(50, "*") '****************this is a string.*****************' >>>s.zfill(50) '000000000000000000000000000000000this is a string.' >>>17as (a)
Original string constant length.