美文网首页
温度转换

温度转换

作者: 南少cc | 来源:发表于2017-07-31 17:59 被阅读0次

    <pre>fahrenheit = 0
    while fahrenheit <= 250:
    celsius = (fahrenheit - 32) / 1.8
    print('%5d %7.2f' % (fahrenheit,celsius)) #等价于print('{:5d} {:7.2f}'.format(fahrenheit, celsius)) #%5d 或者 {:5d} 默认保留5个位置的整数 %7.2f或者{:7.2f} 默认占7个单位的保留两位小数的浮点型
    fahrenheit = fahrenheit + 25</pre>

    相关文章

      网友评论

          本文标题:温度转换

          本文链接:https://www.haomeiwen.com/subject/snvrlxtx.html