有没有一种方法可以在不评估 jupyter notebook 的情况下输出表达式

Is there a way where I can output the expression without evaluation jupyter notebook

我在 jupyter notebook 中创建了一个表达式,现在我想在不计算的情况下显示完整的表达式,我该如何实现。

     from sympy import *

     x,y,z,a,b,c,d = symbols('x,y,z,a,b,c,d')
     pr = (1/a+1/b)**-1
     display(pr))
     init_printing()

可以在 UnevaluatedExpr 中换行:

In [29]: (UnevaluatedExpr(1/a)+1/b)**-1
Out[29]: 
       -1
⎛1   1⎞  
⎜─ + ─⎟  
⎝a   b⎠  

在这种情况下 with sympy.core.evaluate(False): 不起作用。

这在 Advanced Expression Manipulation - Prevent expression evaluation — SymPy 1.7.1 documentation 中已经有很好的解释。