错误类型:'AffineScalarFunc'对象是不可迭代的

2024-05-16 19:36:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我定义了一个函数,例如:

def ucos(a):
    temp=[umath.cos(i) for i in a]
    return unumpy.uarray([unumpy.nominal_values(i) for i in temp], [unumpy.std_devs(i) for i in temp])

但是当我尝试用for循环迭代它时:

^{pr2}$

它给了我一个错误:

TypeError: 'AffineScalarFunc' object is not iterable

你知道为什么ucos函数不可编辑吗?如何使它变得可接受? 谢谢!在


Tags: 函数inforreturn定义defcostemp