主页
Python
Python String format() 方法
demo_string_placeholder23
运行 ❯
×
更改方向
保存代码
更改主题
#Use "%" to convert the number into a percentage format: txt = "You scored {:%}" print(txt.format(0.25)) #Or, without any decimals: txt = "You scored {:.0%}" print(txt.format(0.25))
You scored 25.000000%
You scored 25%