Python memoryview() Function
The memoryview() function in Python returns a memory view object from a specified object.
Syntax
1 2 3 |
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
1 2 3 4 5 6 7 8 |
# 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
1 2 3 4 5 |
<memory at 0x7f5296273cc8> Unicode of the first character: 72 Unicode of the first character: 87 |