Movatterモバイル変換


[0]ホーム

URL:


Python Tutorial

Python Array buffer_info() Method



The Python arraybuffer_info() method is used to retrieve information such as memory address and, length of the array buffer which hold the content of the current array. This method returns the required information in the form of a tuple.

Syntax

Following is the syntax of Python arraybuffer_info() method −

array_name.buffer_info()

Parameters

This method does not accepts any parameters.

Return Value

This method returns a tuple, which contains the memory address and length of an array.

Example 1

Following is the basic example of Python arraybuffer_info method −

import array as arr# Creating an arraymy_array1 = arr.array('i',[400,100,220,400,330,540,540])x = my_array1.buffer_info()print("The address and length of my_array1:", x)

Output

Following is the output of above code −

The address and length of  my_array1: (1579568776016, 7)

Example 2

In this example, we have created an array of thedouble type and retrieved it's address and length usingbuffer_info() method.

import array as arr#Creating an arraymyArray= arr.array('d',[43.5, 5.60, 23.2, 34.6, 7.7])info = myArray.buffer_info()print("Address: ", info[0])print("Length: ", info[1])

Output

Following is the output of above code −

Address:  140381824811680Length:  5
python_array_methods.htm
Print Page
Advertisements

[8]ページ先頭

©2009-2025 Movatter.jp