ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
-
翻译:ValueError:包含多个元素的数组的真值不明确。使用a.any()或a.all()
-
原因:出现了数组的某种运算,且不合运算法则
-
类型:元素的运算,误输入为数组
😊以为的代码,正常运行
a = 1
b = 1
if a==b:
pass
😒错误输入后的代码
a = np.array([1,2,3])
b = np.array([2,3,4])
if a==b :
pass
报错
- 附加 :元组不支持逻辑运算,而元素是支持的
逻辑运算:<, >, ==, !=,…