Home  >  Article  >  Backend Development  >  How to operate Python to traverse numpy array

How to operate Python to traverse numpy array

php中世界最好的语言
php中世界最好的语言Original
2018-04-09 15:45:136256browse

This time I will bring you how to operatePythonTraverse numpyarray, what are the notes when operating Python to traverse numpy array, the following is a practical case, Let’s take a look.

When using python for image processing, sometimes it is necessary to traverse the numpy array. The following is the method of traversing the array:

[rows, cols] = num.shape 
for i in range(rows - 1): 
 for j in range(cols-1): 
  print(num[j, i])

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to obtain the local peak value of a two-dimensional array in python

How to use OpenCV with the Python interface

The above is the detailed content of How to operate Python to traverse numpy array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn