Alignment Methods



Following methods in the str class control the alignment of characters within the string object.

Sr.No. Methods & Description

1

center(width, fillchar)

Returns a string padded with fillchar with the original string centered to a total of width columns.

2

ljust(width[, fillchar])

Returns a space-padded string with the original string left-justified to a total of width columns.

3

rjust(width,[, fillchar])

Returns a space-padded string with the original string right-justified to a total of width columns.

4

expandtabs(tabsize = 8)

Expands tabs in string to multiple spaces; defaults to 8 spaces per tab if tabsize not provided.

5

zfill (width)

Returns original string leftpadded with zeros to a total of width characters; intended for numbers, zfill() retains any sign given (less one zero).

python_string_methods.htm
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy