Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sean-Bradley/cbb4316bff54edd9f3cb103ffc1bad6b to your computer and use it in GitHub Desktop.
Save Sean-Bradley/cbb4316bff54edd9f3cb103ffc1bad6b to your computer and use it in GitHub Desktop.
python print a number with padded zeros, using % rather than .format
iNum = 123 #will always be a number
sPaddingChar = "0"
iNumPads = 6
#print the number with padded zeros, using % rather than .format
print ('%s' % (str(iNum).rjust(iNumPads, sPaddingChar)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment