3 ms·
Something I find useful, and perhaps isn't widely known is that you can pop curly braces into the format part of an f-string to have dynamic formatting: va
by heisenzombie 6y ago
Something I find useful, and perhaps isn't widely known is that you can pop curly braces into the format part of an f-string to have dynamic formatting:
value = 5/6
precision = 2
print(f"{value:.{precision}f}")
> 0.83
- noobermin 6y agoThis is great, had been hacking around this with formatfor years. Will incorporate this soon.