我正在尝试从scipy.constants.physical_constants导入electron volt-joule relationship,以用于数值物理问题。这可能是一个非常简单的问题,或者是对physical_constants字典的误解,但在谷歌了2个小时后,我仍然不知所措。
我试过了
from scipy.constants.physical_constants import electron volt_joule relationship
我也试过了
import scipy.constants.physical_constants["electron volt-joule relationship"]
它会产生
File "<ipython-input-22-7c2fb3ec2156>", line 3 import scipy.constants.physical_constants["electron volt-joule relationship"] ^ SyntaxError: invalid syntax
我是不是误解了这些物理常数的用法?从scipy.org文档中,我看到它们的形式是physical_constantsname =(值,单位,不确定性)
这样我就可以
print(scipy.constants.physical_constants["electron volt-joule relationship"])
返回
(1.602176634e-19, 'J', 0.0)
但即便如此
import scipy.constants.physical_constants
返回以下错误:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-21-b4d34ca28080> in <module>
----> 1 import scipy.constants.physical_constants
ModuleNotFoundError: No module named 'scipy.constants.physical_constants'这个常量库是否充满了您可以引用的值、单位和不确定性,而不是在计算中实际使用的值?
发布于 2021-08-08 18:34:04
看起来原始发帖的import语句的格式不正确。要访问常量,请包括以下import语句:
from scipy import constants然后,要访问特定的常量,请尝试:
print(constants.electron_volt)
returns:
1.602176634e-19如果没有找到scipy包,可以使用以下命令添加:
pip install scipyhttps://stackoverflow.com/questions/67101481
复制相似问题