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

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

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

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

語(yǔ)法

memoryview 語(yǔ)法:memoryview(obj)

參數(shù)說(shuō)明:obj -- 對(duì)象

返回值:返回元組列表。

英文文檔:

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.

說(shuō)明:

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

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

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

示例

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

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

相關(guān)文章

最新評(píng)論