使用sympy
1.解一元方程 x^2+2x=0
from sympy import * x=Symbol('x') print(x,solve(x**2+2*x))
2.解二元方程组 x+y=4 2x+3y=10
from sympy import * x,y=symbols('x y') sol=solve((x+y-4, 2*x+3*y-10)) print(sol)
运行结果: