a = np.random.randint(1,100,(5,5))
max=a[0]
for n in range(1,100):
if(a[n] > max):
max = a[n]
print(max)
当我运行它时;它给出了这个错误
if(a[n] > max):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我尝试修复它,但它给出了另一个错误
a = np.random.randint(1,100,(5,5))
max=a[0]
for n in range(1,100):
if(a[n].all > max):
max = a[n]
print(max)
当我再次运行时会弹出此错误
if(a[n].all > max):
TypeError: '<' not supported between instances of 'int' and 'builtin_function_or_method'
温温酱
ibeautiful
相关分类