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

简介: 成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or

解决问题


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




解决思路


值错误:包含一个以上元素的数组的真值是不明确的,要使用a.any()或a.all()





解决方法



   if data_z==data_x:

       print('data_x等价于data_z')


改为


   if data_z.all()==data_x.all():

       print('data_x等价于data_z')


相关文章
|
3月前
|
Java
java lab8--------7-2 sdut-JAVA-Insert Integer element into array lists
java lab8--------7-2 sdut-JAVA-Insert Integer element into array lists
21 0
|
5月前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
276 0
|
Python
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
452 0
LeetCode 215. Kth Largest Element in an Array
在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。
79 0
|
人工智能 C++ Python
LeetCode 961. N-Repeated Element in Size 2N Array
LeetCode 961. N-Repeated Element in Size 2N Array
188 0
PHP:Cannot use object of type stdClass as array
PHP:Cannot use object of type stdClass as array
175 0
|
PHP
【PHP】Cannot use object of type stdClass as array
【PHP】Cannot use object of type stdClass as array
739 0
【PHP】Cannot use object of type stdClass as array
成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
|
Python
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
913 0
|
5月前
|
Python
使用array()函数创建数组
使用array()函数创建数组。
86 3