📅  最后修改于: 2023-12-03 15:20:00.714000             🧑  作者: Mango
SciPy 是一个 Python 的开源库,用于科学计算、数学和工程学。它包含了很多科学计算中需要用到的函数,其中包括了很多常量。在本篇文章中,我们将为大家介绍 SciPy 常量。
在 SciPy 中,常量是指不会改变的数值。包含了数学中的一些经典常量如 pi,e,常见物理常量如光速,万有引力常数等等。SciPy 定义的常量可以让我们更加方便快捷地使用它们。
SciPy 常量可以通过导入 scipy.constants 模块的方式使用。下面我们将介绍一些常用的 SciPy 常量。
from scipy.constants import pi
print(pi)
输出结果为:
3.141592653589793
from scipy.constants import e
print(e)
输出结果为:
2.718281828459045
from scipy.constants import golden
print(golden)
输出结果为:
1.618033988749895
from scipy.constants import c
print(c)
输出结果为:
299792458.0
from scipy.constants import h
print(h)
输出结果为:
6.62607015e-34
from scipy.constants import G
print(G)
输出结果为:
6.67430e-11
from scipy.constants import m_e
print(m_e)
输出结果为:
9.10938356e-31
from scipy.constants import m_p
print(m_p)
输出结果为:
1.672621922e-27
本文介绍了常用的 SciPy 常量,包括数学常量和物理常量。我们可以使用 SciPy 定义的这些常量,更加方便地进行科学计算。如果想了解更多的常量以及 SciPy 中的其他功能,请阅读 SciPy 官方文档。