互联网技术 / 互联网资讯 · 2024年3月10日

Python内置函数-round()函数的详细解析

描述

Round() 方法返回浮点数x的四舍五入值。

语法

以下是 Round() 方法的语法:

Round( x [, n] )

参数

x — 数值表达式。

n — 数值表达式,表示从小数点位数。

返回值

返回浮点数x的四舍五入值。

实例

以下展示了使用 Round() 方法的实例:

云计算开发:Python内置函数-round()函数详解

以上实例运行后输出结果为:

云计算开发:Python内置函数-round()函数详解

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.