Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
num = 10
# %
print("%d" % num) # 10
print("%2d" % num) # 10
print("%3d" % num) # 10
print("%02d" % num) # 10
print("%03d" % num) # 010
# format
print("{0:d}".format(num)) # 10
print("{0:2d}".format(num)) # 10
print("{0:3d}".format(num)) # 10
print("{0:02d}".format(num)) # 10
print("{0:03d}".format(num)) # 010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment