欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python 內(nèi)置函數(shù)memoryview(obj)的具體用法

 更新時間:2017年11月23日 11:16:55   作者:十月狐貍  
本篇文章主要介紹了Python 內(nèi)置函數(shù)memoryview(obj)的具體用法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

memoryview() 函數(shù)返回給定參數(shù)的內(nèi)存查看對象(Momory view)。

語法

memoryview 語法:memoryview(obj)

參數(shù)說明:obj -- 對象

返回值:返回元組列表。

英文文檔:

class memoryview(obj)

memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying.
Create a memoryview that references obj. obj must support the buffer protocol. Built-in objects that support the buffer protocol include bytes and bytearray.

說明:

  1. 函數(shù)功能返回內(nèi)存查看對象,實際上是內(nèi)存查看對象(Momory view)的構(gòu)造函數(shù)。

  2. 所謂內(nèi)存查看對象,是指對支持緩沖區(qū)協(xié)議的數(shù)據(jù)進行包裝,在不需要復(fù)制對象基礎(chǔ)上允許Python代碼訪問。

  3. Python內(nèi)置對象中支持緩沖區(qū)協(xié)議的對象有bytes和bytearray。

示例

>>> v = memoryview(b'abcefg')
>>> v[1]
98
>>> v[-1]
103
>>> v[1:4]
<memory at 0x7f3ddc9f4350>
>>> bytes(v[1:4])
b'bce'

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論