Python memoryview() Function

Instance

Create and print memoryview object:

x = memoryview(b"Hello")
print(x)
# Returns the Unicode of the first character
print(x[0])
# Returns the Unicode of the second character
print(x[1])

Running Instance

Definition and Usage

The memoryview() function returns a memory view object from the specified object.

Syntax

memoryview(obj)

Parameter Value

Parameter Description
obj Byte object or byte array object.