python报错:ValueError: The truth value of an array with more than one element is ambiguous. Use a.any(

在判断多元素数组是否为空时,报了这个错

if a:	# a是含有多个元素的numpy数组
	xxx

python报错:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

含有多个元素的数组在判断比较所有元素时,要用以上给定的any()all()方法

参考解决方案:学习随笔-ValueError: The truth value of an array with more than one element is ambiguous

发布了974 篇原创文章 · 获赞 73 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/Dontla/article/details/105112136