f"{int(number):>20,}"
Of course I can do f"{123456:>20_}".replace("_", " "), just thought there >might be something else my search mojo fails on.
Looks like this "replace" deal is the go-to move, no two ways
about it. If there's some neck of the woods where it's SOP, you
might wanna roll with "locale.format_string". (Whipping up a custom
locale just for kicks is usually more trouble than it's worth.)
The German DIN 5008 (their fancy-schmancy rules for writing
and formatting) now says you got to use /spaces/ to separate
thousands, and only recommends using periods for cold hard cash.
On Fri, 30 Aug 2024 05:22:17 GMT, Gilmeh Serda wrote:
f"{int(number):>20,}"
I can find "," (comma) and I can find "_" (underscore) but how about " " (space)?
Or any other character, for that matter?
Any ideas?
Of course I can do f"{123456:>20_}".replace("_", " "), just thought there might be something else my search mojo fails on.
On 2024-08-31 06:31, Gilmeh Serda via Python-list wrote:
On Fri, 30 Aug 2024 05:22:17 GMT, Gilmeh Serda wrote:The format is described here:
f"{int(number):>20,}"
I can find "," (comma) and I can find "_" (underscore) but how about " "
(space)?
Or any other character, for that matter?
Any ideas?
Of course I can do f"{123456:>20_}".replace("_", " "), just thought there
might be something else my search mojo fails on.
https://docs.python.org/3/library/string.html#formatspec
A space is counted as a fill character.
Looks like this "replace" deal is the go-to move,
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 994 |
Nodes: | 10 (0 / 10) |
Uptime: | 97:10:07 |
Calls: | 13,016 |
Calls today: | 2 |
Files: | 186,574 |
Messages: | 3,282,095 |