带有1个小数的计算的打印结果

时间:2018-11-03 23:44:15

标签: python map-projections

作为Python的初学者,我偶然发现了一个看似简单的代码,我无法使其正常工作。

我正在尝试输出带有1个十进制数字的计算输出,这是我尝试过的代码的版本之一。我也尝试过使用format(x/s, '.1f'),但是这些都不起作用。

我的代码有一部分:

for v in range(n):
    #It will repeat the calculation the many times its defined in n input
    x = R*(v*n)
    if x/s*100<100:
        print("meridian will be", '%.1f' % x/s*100, "cm from center")
    else x/s*100>100:
        print("meridian will be - cm from center")

使用'%.1f'似乎无效,语法是否错误?我真的不确定...

0 个答案:

没有答案
相关问题