- SciPy 教程
- SciPy - 主頁
- SciPy - 簡介
- SciPy - 環境設定
- SciPy - 基本功能
- SciPy - 群集
- SciPy - 常量
- SciPy - FFTpack
- SciPy - 整合
- SciPy - 插值
- SciPy - 輸入和輸出
- SciPy - 線性代數
- SciPy - N 維影像
- SciPy - 最佳化
- SciPy - 統計
- SciPy - 計算圖
- SciPy - 空間
- SciPy - ODR
- SciPy - 特殊軟體包
- SciPy 實用資源
- SciPy - 參考資料
- SciPy - 快速指南
- SciPy - 實用資源
- SciPy - 討論
SciPy - unit() 方法
SciPy unit() 方法用於透過詞典從物理常量中訪問特定單位。此方法包含值和單位。它定義在 scipy.constants 模組中。此函式的主要用途允許使用者計算準確的科學計算。
語法
以下是 SciPy unit() 方法的語法 −
unit(key)
引數
此方法僅接受一個引數 −
- key:此引數優先作為指定物理常量名稱的字串。
返回值
此方法重新執行一個整數。
示例 1
以下是基本的 SciPy unit() 方法,它展示了物理常量(“真空中的光速”)的用法。
from scipy.constants import physical_constants
key = 'speed of light in vacuum'
unit = physical_constants[key][2]
print(f"The unit of {key} is {unit}.")
輸出
上述程式碼產生以下結果 −
The unit of speed of light in vacuum is 0.0.
示例 2
在這裡,我們使用物理常量的鍵為 “普朗克常數”,它有助於以單位形式顯示結果。
from scipy.constants import physical_constants
key = 'Planck constant'
unit = physical_constants[key][0]
print(f"The unit of {key} is {unit}.")
輸出
上述程式碼產生以下結果 −
The unit of Planck constant is 6.62607015e-34.
scipy_reference.htm
廣告