擅长:python、mysql、java
<p>使用<a href="https://quantiphy.readthedocs.io/en/stable" rel="nofollow noreferrer">QuantiPhy</a>包。它是一个稳定的、有良好文档记录和良好支持的包,旨在满足您的需要。在</p>
<pre><code>>>> from quantiphy import Quantity
>>> all = dict(
... a = Quantity('1u'),
... b = Quantity('2m'),
... c = Quantity('1.1u)'
... )
>>> for n, v in all.items():
... print(f'{n} = {v:<0.7f}')
a = 0.000001
b = 0.002
c = 0.0000011
</code></pre>
<p>Quantity子类float,因此可以在任何可以使用float的地方使用Quantity。在</p>
^{pr2}$
<p>打印时可以保留SI比例因子。也可以添加单位以使数量更具描述性。在</p>
<pre><code>>>> all = dict(
... a = Quantity('1ug'),
... b = Quantity('2mg'),
... c = Quantity('1.1ug)'
... )
>>> for n, v in all.items():
... print(f'{n} = {v}')
a = 1 ug
b = 2 mg
c = 1.1 ug
</code></pre>
<p>它还提供了更多的功能。在</p>