amount = 12345678901234567890
print(format(amount, '+_d'))
print(format(-255, '#012_x'))
ratio = 1.25
width = 10
precision = 2
print(f'{ratio:🐍^{width}.{precision}f}')
print(format(100.0, '.3'), format(100.0, '.3g'))
print(format(0.125, '+.1%'))
print(format('Zoë 🐍', '*>١٠.٥s'))
value = complex(-0.0, -2.5)
print(format(value, '>16'), format(value, '+.2f'))
class Label:
    def __init__(self, text):
        self.text = text
    def __format__(self, spec):
        return '[' + format(self.text, spec) + ']'
label = Label('ready')
print(f'{label:^9}')
formatter = format
print(formatter(*(True, '04d')))
try:
    formatter(42, '.2d')
except ValueError as error:
    print(type(error).__name__, str(error))
