Non-commutative sympify (or simplify)
问题 I would like to be able to simplify mathematical expressions from a string in Python. There are several "commutative" ways of doing it. Is there a non-commutative function for that? I know that sympify from sympy can do some non-commutative jobs, here you have an example: from sympy import * x=Symbol('x',commutative=False) y=Symbol('y',commutative=False) print sympify(3*x*y - y*x - 2*x*y) it will print x y -y x, however if we apply sympify to the string, that is, print sympify('3*x*y - y*x -