定义一个小数scale, 输出 数据比例是 25.00%
# 定义一个小数scale, 输出 数据比例是 25.00% scale = 0.25 print("数据比例是 %.2f%%" % (scale * 100))
注意两个地方: 1.格式化输出%,要使用%% 2.scale转化为整数,乘100要加括号,否则会将字符串重复100次