Python Sympy系数与as_独立不一致
我有以下代码片段Python Sympy系数与as_独立不一致,python,sympy,Python,Sympy,我有以下代码片段 import sympy a = sympy.symbols('a') b = sympy.symbols('b') c = sympy.symbols('c') print((a*b).coeff(c,0)) print((a*b).as_independent(c)[0]) 我不明白为什么这两个print语句打印不同的输出。根据coeff的文件: You can select terms independent of x by making n=0; in this
import sympy
a = sympy.symbols('a')
b = sympy.symbols('b')
c = sympy.symbols('c')
print((a*b).coeff(c,0))
print((a*b).as_independent(c)[0])
我不明白为什么这两个print语句打印不同的输出。根据coeff的文件:
You can select terms independent of x by making n=0; in this case
expr.as_independent(x)[0] is returned (and 0 will be returned instead
of None):
>>> (3 + 2*x + 4*x**2).coeff(x, 0)
3
这是sympy中的一个bug,还是我错过了什么?这是一个bug。我有个修车请求 这看起来像个虫子。你能吗?我已经搞定了。