I have a number 1234567.12. I'm trying to center it in a field of 20, with 3 decimal places, commas as separators and pad the left and right sides with *. Here's what I did: (Python3.11)
value = 1234567.12
y = f'{value:,.3f}'
x = f'{y:*^20}'
which is also equivalent to:
x = f'{f"{value:,.3f}":*^20}'
is there a cleaner syntax?
According to the specifications of the format mini-language:
you can just put
fill(*),align(^) andwidth(20) beforegrouping_option(,):