英文文档:

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. 函数功能返回内存查看对象,实际上是内存查看对象(Momory view)的构造函数。

  2. 所谓内存查看对象,是指对支持缓冲区协议的数据进行包装,在不需要复制对象基础上允许Python代码访问。

  3. Python内置对象中支持缓冲区协议的对象有bytes和bytearray。

  1. >>> v = memoryview(b'abcefg')
  2. >>> v[1]
  3. 98
  4. >>> v[-1]
  5. 103
  6. >>> v[1:4]
  7. <memory at 0x7f3ddc9f4350>
  8. >>> bytes(v[1:4])
  9. b'bce'

Python内置函数(42)——memoryview的更多相关文章

  1. Python内置函数(15)——memoryview

    英文文档: class memoryview(obj) memoryview objects allow Python code to access the internal data of an o ...

  2. Python内置函数(42)——hash

    英文文档: hash(object)Return the hash value of the object (if it has one). Hash values are integers. The ...

  3. Python内置函数和内置常量

    Python内置函数 1.abs(x) 返回一个数的绝对值.实参可以是整数或浮点数.如果实参是一个复数,返回它的模. 2.all(iterable) 如果 iterable 的所有元素为真(或迭代器为 ...

  4. Python | 内置函数(BIF)

    Python内置函数 | V3.9.1 | 共计155个 还没学完, 还没记录完, 不知道自己能不能坚持记录下去 1.ArithmeticError 2.AssertionError 3.Attrib ...

  5. Python内置函数(12)——str

    英文文档: class str(object='') class str(object=b'', encoding='utf-8', errors='strict') Return a string  ...

  6. Python内置函数(61)——str

    英文文档: class str(object='') class str(object=b'', encoding='utf-8', errors='strict') Return a string ...

  7. Python 内置函数笔记

    其中有几个方法没怎么用过, 所以没整理到 Python内置函数 abs(a) 返回a的绝对值.该参数可以是整数或浮点数.如果参数是一个复数,则返回其大小 all(a) 如果元组.列表里面的所有元素都非 ...

  8. 【转】python 内置函数总结(大部分)

    [转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...

  9. python内置函数,匿名函数

    一.匿名函数 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

随机推荐

  1. 服务器Nginx 反向代理 其他服务器 8181端口 失败的问题

    排查方向: 1. 检查服务器的防火墙 2. 检查安全策略 3. 关掉Nginx 服务器上的安全软件 如360 软件会照成这个问题 来自为知笔记(Wiz)

  2. Python @property 详解

    本文讲解了 Python 的 property 特性,即一种符合 Python 哲学地设置 getter 和 setter 的方式. Python 有一个概念叫做 property,它能让你在 Pyt ...

  3. python中用xlsxwriter创建图表

    缺点:xlsxwriter不能对已存在的Excel进行编辑插入图标   生成图标需要: 1.先准备数据 2.将数据插入到excel中 3.根据插入的数据生成图表 这里的生成excel主要分为准备多维数 ...

  4. Python程序的执行过程原理(解释型语言和编译型语言)

    Python是一门解释型语言?我初学Python时,听到的关于Python的第一句话就是Python是一门解释型语言,我就这样一直相信下去,直到发现.pyc文件的存在,如果真是解释型语言,那么生成的. ...

  5. Spring 1 控制反转、依赖注入

    1.1 Spring的核心是控制反转(IoC)和面向切面(AOP) 学习spring之前的开发中通过new创建一个对象,有了spring之后,spring创建对象实例-IoC控制反转,之后需要实例对象 ...

  6. Little Sub and Isomorphism Sequences ZOJ - 4089

    ZOJ - 4089 思路:可以反正 最长重构序列必然符合  此模式 x  +  {   }  与  {   }  +  x 那么 题意转化为了  找两个距离最长的相同的数.eeee 先离散化 然后 ...

  7. Ubuntu14.04下如何配置固定IP

    首先用root用户登陆,然后输入你root的密码.如下图:   然后编辑interfaces文件,该文件位于/etc/network/下,执行如下命令: vim /etc/network/interf ...

  8. go web开发(gin&gorm) 之DB配置及DAO的基本使用

    转载请注明出处: https://www.cnblogs.com/funnyzpc/p/9501376.html ```   我先闲扯下,前天(也就是2018年11月16号)的某个时候,忽然有人在QQ ...

  9. cookie设置域名问题,cookie跨域

    今天研究一天发现cookie无法设置除当前域名或者其父域名之外的其他domain. 这个是浏览器出于对cookie的保护造成的,也就是cookie无法跨域设置. 对于子域名也有如下规则,当前域名只能设 ...

  10. LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++>

    LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++> 给出排序好的 ...