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

你可能感兴趣的:(Python)