Python math.pi 常量

定义和用法

math.pi 常量返回 pi 的值:3.141592653589793。

它被定义为圆的周长与其直径的比率。

注意:数学上,pi 用 π 来表示。

实例

打印 PI 的值:

# 打印 PI 的值:
import math 

# 打印 pi 的值
print (math.pi)

亲自试一试

语法

math.pi

技术细节

返回值: 浮点数值,3.141592653589793,代表数学常数 PI。
Python 版本: 1.4