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(myarray[i][j])”的型別是“int”,所以我不知道出了什么問題。
uj5u.com熱心網友回復:
你不會重新初始化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://www.uj5u.com/houduan/529469.html
