lang/python/ PythonNumberFormatting


Precision and zero-padding

x = 1
y = 3.14
print(f"{x} {x=} {x:05d} {y:0.05f}")

prints

1 x=1 00001 3.14000

commas

To separate digits with a comma

x = 2432243242
print(f"{x=:,}")

prints

x=28,429,834,982