I know that I can to the following. But is it possible to combine them to give me a percent with fixed decimal?
>>> print(f'{0.123:%}')
12.300000%
>>> print(f'{0.123:.2f}')
0.12
But what I want is this output:
12.30%
CodePudding user response:
You can specify the number of decimal places before %
:
>>> f'{0.123:.2%}'
'12.30%'