round
请查看 Python 内建函数列表 了解更多相关 API。
说明:求近似值。
python
def round(number, ndigits=None):
'''
求近似值
:param number: 要计算的值
:param ndigits: 保留的位数
:return: 近似值
'''示例:
python
print(round(3.1415926))
print(round(3.1415926, 2))
print(round(2.71828))
print(round(2.71828, 2))