Python String Format Percentage From Float Value

July 25, 2019

Using String Format

value = 0.015
print("{0:.2%}".format(0.015))  # '1.50%'

Using String Literal

value = 0.015
print(f"{value:.2%}")           # '1.50%'
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.