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提示这样一个错误:

#数据是这样来的
# features = np.asarray(features_array)
# 出错语句:
if (features == None):
    return
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

这意思就是说,如果是数组,不能这样判断。需要a.all()判断。

  如果是None,那么怎么办?所以吾干脆加了个初始化标志来处理这个问题。

......
InitedFlag=False
InitedFlag=True
if (InitedFlag == False):
    return
目录
相关文章
|
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
|
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
成功解决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
成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
|
算法 Java
LeetCode 229 Majority Element II(主要元素II)(Array)(Boyer–Moore majority vote algorithm)
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/52356817 原文 给定一个长度为n的整型数组,找出所有出现超过 ⌊ n/3 ⌋ 次的元素。
1027 0