使用math.sin时报错only size-1 arrays can be converted to Python scalar
代码:importnumpyasnpx=np.linspace(0,1,6)deff(x):returnmath.sin(x)y=f(x)报错:onlysize-1arrayscanbeconvertedtoPythonscalars解决方案:用numpy里的sin代替math库里的sinimportnumpyasnpx=np.linspace(0,1,6)deff(x):returnnp.sin