View Subcategory
Zero pad a number
Given the number 42, pad it to 8 characters like 00000042
python
"%08d" % 42
Right Space pad a number
Given the number 1024 right pad it to 6 characters
"1024 "
python
"%-6s" % 1024
str(1024).rjust(6)
'{0: <6}'.format(1024)
Format a decimal number
Format the number 7/8 as a decimal with 2 places: 0.88
python
"%.2f" % (7 / 8.0)
round(7./8., 2)
Left Space pad a number
Given the number 73 left pad it to 10 characters
" 73"
python
"%10s" % 73
