Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string formatting - padding

# string padding with left alignment
print("{:5}".format("cat"))

# string padding with right alignment
print("{:>5}".format("cat"))

# string padding with center alignment
print("{:^5}".format("cat"))

# string padding with center alignment
# and '*' padding character
print("{:*^5}".format("cat"))
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #python #string #formatting #padding
ADD COMMENT
Topic
Name
1+1 =