用户输入一个小数,用format格式化输出,保留3位小数 number = float(input("输入一个数:")) print("这个数保留3位小数为:{:.3f}".format(number)) 结果为