所以我需要做一些划分。有谁知道如何输出保留三位小数的结果?例如:--> 5/2 = 2.500 8/6 = 1.333 10/3 = 3.333
尝试过的代码:
a = int(input())
b = int(input())
print(a/b)
你可以看到,如果输入是5和2,它将输出2.5(不是小数点后3位)
print(f'{a/b:.3f}')
格式化迷你语言手册:https://docs.python.org/3/library/string.html#formatspec