June 2002
Beginner to intermediate
640 pages
14h 24m
English
The functions for adjusting text are as handy and convenient as the parsing functions. You'll use them a lot, particularly for attractive report printing.
The ljust(s, width) function left-justifies a string to a given width. The rjust(s, width) function right-justifies it. The center(s, width) function centers a string to a given width. Here are examples of all three:
>>> rjust("String",20)
' String'
>>> rjust ("str",20)
' str'
>>> ljust("String",20)
'String '
>>> ljust("str",20)
'str '
>>> center("str",20)
' str '
>>> center("String",20)
' String '
zfill(snum,width) pads a numeric string with leading zeros.
>>> zfill("0.1", 10)
'00000000.1'
expandtabs(s,tabsize) converts ...
Read now
Unlock full access