如何在Python计算器中显示数字而不使用科学符号?

2024-03-29 11:06:32 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使数字显示如下:

$25.23   

而不是这个

$2.5 e+02

除了关于如何做到这一点,为什么它被显示在科学记数法

此外,如果有必要,我正在尝试制作一个价格计算器,因此我需要将价格显示为:

xyz.wd

我正在使用的当前代码:

p1= float(input("Price:"))
d= float(input("discount percentage:"))
discount = p1*(d/100)
p2 = p1-discount
print(f"discount value: ${discount:10.2}")
print(f"final value: ${p2:10.2}")

Tags: 代码inputvalue价格discount数字科学float