rows = len(myarray[0,:])
columns = len(myarray[:,1])
number_of_coordinates = 0
i=0
j=0
while i < rows:
while j < columns:
if int(myarray[i][j]) == 1:
print("Found one!")
number_of_coordinates += 1
j += 1
i += 1
print(number_of_coordinates)应该打印出一个很高的数字,我知道这个数组中有很多1和整数2-10。"int(myarrayi)“的类型是"int”,所以我不知道出了什么问题。
发布于 2022-11-04 16:24:45
如果不将j重新初始化为零,
rows = len(myarray[0,:])
columns = len(myarray[:,1])
number_of_coordinates = 0
i=0
j=0
while i < rows:
while j < columns:
if int(myarray[i][j]) == 1:
print("Found one!")
number_of_coordinates += 1
j += 1
i += 1
j = 0 # Look at it
print(number_of_coordinates)假设您正在使用Python。
https://stackoverflow.com/questions/74320068
复制相似问题