这不是代码修订版,因此我在这里创建了线程。我的任务如下:
Write a program which: 1. intializes a variable a with 123, and prints the value of a over 7 places, 2. intializes a variable b with -89.6548754, and prints the value of b over 10 places and with a floating point precision of 4
第一个是:
a = 123
print("The value is {0:7d}".format(a))
我不明白的是第二个。什么是“浮点精度4”?这是什么意思?我想这意味着要把小数位数(即7(6548754))缩短到4。你知道吗
b=-89.6548754
print("The value is {:10.4f}".format(b))
从format string mini-language specification:
是的,它是小数点后的位数。你知道吗
相关问题 更多 >
编程相关推荐