轻松上手,快乐学习!

Python memoryview() 函数


实例

创建和打一个内存视图对象
x = memoryview(b"Hello")

print(x)

#return the Unicode of the first character
print(x[0])

#return the Unicode of the second character
print(x[1])
运行实例 »

定义和用法

memoryview()函数返回指定对象的内存视图对象。

语法

memoryview(obj)

参数值

参数 描述
obj Bytes对象或Bytearray对象。