SymPy equivalent to HoldForm in mathematica
问题 In Mathematica, it is possible to prevent the system from simplifying expressions when they are entered. The syntax is as follows: HoldForm[x/x] Is it possible to do something similar with SymPy? 回答1: The following approaches achieve a similar effect. There might be others available I am not aware of. import sympy as sp x = sp.symbols('x') expr1 = x/x expr2 = sp.S('x/x', evaluate=False) expr3 = sp.Mul(x, 1/x, evaluate=False) print(expr1) print(expr2) print(expr3) 1 x/x x/x 回答2: You can also