jlc*_*lin 3 python units-of-measurement
我正在使用Python的大量包.我想知道如何在没有单位的情况下得到数量的数值.
即,如果我有
E = 5.3*quantities.joule
Run Code Online (Sandbox Code Playgroud)
我想达到5.3.我知道我可以简单地除以"不受欢迎的"单位,但希望有更好的方法来做到这一点.
E.item()似乎是你想要的,如果你想要一个Python浮点数.E.magnitude由tzaman提供,如果您愿意的话,它是一个带有值的0维NumPy数组.
该文档quantities似乎没有非常好的API参考.