Python String Literal Format Float

July 15, 2019
num = 0.1 + 0.05

out = f"num={num}"      # 'num=0.15000000000000002'
out = f"num={num:.4f}"  # 'num=0.1500'
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.