天天看點

【TypeError: only length-1 arrays can be converted to Python scalars】

今天寫python代碼:

當用到math.log()函數值,總是出現如下錯誤:

TypeError: only length-1 arrays can be converted to Python scalars

原因:math.log()不能對矩陣進行直接操作。

【TypeError: only length-1 arrays can be converted to Python scalars】

經過測試,發現:

【TypeError: only length-1 arrays can be converted to Python scalars】
【TypeError: only length-1 arrays can be converted to Python scalars】
【TypeError: only length-1 arrays can be converted to Python scalars】
【TypeError: only length-1 arrays can be converted to Python scalars】