Python memoryview() Function
Python memoryview() Function
The memoryview() function in Python returns a memory view object from a specified object.
Syntax
memoryview(obj)
Parameter
obj: This parameter represents a Bytes object or a bytearray object.
Return
This function returns a “memory view” object created from the given argument.
Example 1
# Python program explaining
# the memoryview() function
inp_str = memoryview(b"Hello World")
print(inp_str)
print("Unicode of the first character: ",inp_str[0])
print("Unicode of the seven character: ",inp_str[6])
Output
<memory at 0x7f5296273cc8> Unicode of the first character: 72 Unicode of the first character: 87
