本文实例讲述了Python求导数的方法。分享给大家供大家参考。具体实现方法如下:
def func(coeff):
sum=''
for key in coeff:
sum=sum+'+'+str(key)+'*'+'x'+'**'+str(coeff[key])
return sum[1:]
from sympy import *
from sympy.core.sympify import SympifyError
expr = func({2:0,3:1,4:2,5:7})
x = Symbol("x")
sexpr = sympify(expr)
print di
1