SoFunction
Updated on 2024-11-17

Python simple way to get the number of rows and columns of a two-dimensional array example

This article example describes the Python simple way to get the number of rows and columns of a two-dimensional array. Shared for your reference, as follows:

import numpy as np
x = ([[1,2,5],[2,3,5],[3,4,5],[2,3,6]])
# Output the number of rows and columns of the array
print  # (4, 3)
# Output only the number of rows
print [0] # 4
# of columns output only
print [1] # 3

The results of the native test run are shown below:

Or:

>>> arr = [[1,4,7,10,15], [2,5,8,12,19], [3,6,9,16,22], [10,13,14,17,24]]
>>> len(arr) # of lines
4
>>> len(arr[0]) # of columns
5

Readers interested in more Python related content can check out this site's topic: theSummary of Python array manipulation techniques》、《Summary of Python mathematical operations techniques》、《Python Data Structures and Algorithms Tutorial》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques

I hope that what I have said in this article will help you in Python programming.