如何使用handcalcs和forallpeople Python库使平方根计算后的结果显示单位?

问题描述 投票:0回答:1

我正在 handcalcs Python 库中使用 forallpeople Python 库。进行平方根计算后,计算结果中没有显示单位:

import handcalcs.render
from math import sqrt, pi
import forallpeople as si
si.environment('structural', top_level=True)

计算如下:

%%render 1 short
A = (78.3*MPa)
B = (56.6*MPa)
C = (80.4*MPa)
D = sqrt(A**2 + B**2 + C**2)

这是输出:

The output of the calculation

我想知道是否有办法让单位显示出来,即

D = ... = 125.7 MPa

python jupyter-lab
1个回答
0
投票

我按照

forallpeople
手册进行操作,其中有策略1 - 手动重新添加单位并且它起作用了。

%%render 1 short
A = (78.3*MPa)
B = (56.6*MPa)
C = (80.4*MPa)
D = (sqrt(A**2 + B**2 + C**2)*MPa)
© www.soinside.com 2019 - 2024. All rights reserved.