至尊宝的传说
当您查看在 scipy 模块中如何定义 fsolve 时,我们会看到:def fsolve(func, x0, args=(), fprime=None, full_output=0, col_deriv=0, xtol=1.49012e-8, maxfev=0, band=None, epsfcn=None, factor=100, diag=None): """ Find the roots of a function. Return the roots of the (non-linear) equations defined by ``func(x) = 0`` given a starting estimate. Parameters ---------- func : callable ``f(x, *args)`` A function that takes at least one (possibly vector) argument, and returns a value of the same length. '''因此,您的 p 输入值应该包含与您的函数返回的元素一样多的元素。尝试例如:from scipy.optimize import fsolveimport numpy as npdef equations(p): x1 = p[0] x2 = p[1] return x1-8, x2**2 - 64x = fsolve(equations, np.array([1, 2]))print(x)给出 8, 8 作为答案。