Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string formatting - string truncating with format()

# truncating strings to 3 letters
print("{:.3}".format("caterpillar"))

# truncating strings to 3 letters
# and padding
print("{:5.3}".format("caterpillar"))

# truncating strings to 3 letters,
# padding and center alignment
print("{:^5.3}".format("caterpillar"))
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #python #string #formatting #string #truncating
ADD COMMENT
Topic
Name
3+5 =