I am a new Python user, and am struggling with what is seemingly a very easy problem — yet I cannot seem to solve it. The problem is that I created an array from np that contains a single value.
In: distance_index
Out: (array([14], dtype=int64),)
In: type(distance_index)
Out: tuple
So, my question is simple...I need to grab the value of 14 from the array so that I can use it in another part of the code.
To get any index of your array just use "array[index]". Keep in mind arrays start at 0
print(distance_index[0])
However, as @Christian Dean points out, this question deals with an array in a tuple. So you need:
print(distance_index[0][0])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.