Sujet : Re: Is there a better way? [combining f-string, thousands separator, right align]
De : pf (at) *nospam* pfortin.com (Pierre Fortin)
Groupes : comp.lang.pythonDate : 26. Aug 2024, 03:38:22
Autres entêtes
Message-ID : <mailman.2.1724637291.2917.python-list@python.org>
References : 1 2
User-Agent : Claws Mail 4.3.0git9 (GTK 3.24.43; x86_64-pc-linux-gnu)
On Sun, 25 Aug 2024 15:12:20 GMT Gilmeh Serda via Python-list wrote:
Subject explains it, or ask.
>
This is a bloody mess:
>
s = "123456789" # arrives as str
f"{f'{int(s):,}': >20}"
' 123,456,789'
>
Oops.. forgot comma
f"{int(s):>20,}"