问题描述
x = [1,2,3,4,5,6,7]
y = [1,8,44,0]
我将其转换为数组:
x = np.array(x)
y = np.array(y)
当我尝试为指定的 x 范围打印相应的 y 值时,比如 x
y_new = y[x < 5]
print(y_new)
Output: [1 3 5 8]
但是,当我尝试检索 1
y_1_5 = y[1 < x < 5]
y_15 = y[x > 1 and x < 5]
print(y_1_5)
print(y_15)
Ouput: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
由于我想打印 1
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)