python __builtins__ bytes类 (8)】的更多相关文章

8.'bytes', 字符串转换成字节流.第一个传入参数是要转换的字符串,第二个参数按什么编码转换为字节. class bytes(object) | bytes(iterable_of_ints) -> bytes # bytes([1, 2, 3, 4]) bytes must be in range(0, 256) | bytes(string, encoding[, errors]) -> bytes # bytes('你妈嗨', encoding='utf-8') | bytes(b…
参考:中文维基 二进制 位操作(wiki) Byte字节 互联网数据处理:Base64数据编码 Python的模块Base64 16进制简介 python: bytes对象 字符集介绍:ascii 二进制简介: In mathematics and digital electronics, a binary number is a number expressed in the base-2 numberal system or binary numeral system, which uses…
46.'memoryview',  返回给定参数的内存查看对象(Momory view).所谓内存查看对象,是指对支持缓冲区协议的数据进行包装,在不需要复制对象基础上允许Python代码访问. class memoryview(object) | Create a new memoryview object which references the given object. | | Methods defined here: | | __delitem__(self, key, /) | De…
6.'bool',  函数用于将给定参数转换为布尔类型,如果没有参数,返回 False. class bool(int) # 继承于int类型 | bool(x) -> bool # 创建bool类型的对象 | | Returns True when the argument x is true, False otherwise. # 参数x为真返回True,否则返回False. | The builtins True and False are the only two instances o…
65.'str', 字节转换成字符串.第一个传入参数是要转换的字节,第二个参数是按什么编码转换成字符串 class str(object) | str(object='') -> str | str(bytes_or_buffer[, encoding[, errors]]) -> str | | Create a new string object from the given object. If encoding or | errors is specified, then the ob…
64.'staticmethod', 返回静态方法 class staticmethod(object) | staticmethod(function) -> method | | Convert a function to be a static method. | | A static method does not receive an implicit first argument. | To declare a static method, use this idiom: | | c…
60.'set',  转换为集合类型 class set(object) | set() -> new empty set object | set(iterable) -> new set object | | Build an unordered collection of unique elements. | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __contain…
42.'list', 转换为列表类型 class list(object) | list() -> new empty list | list(iterable) -> new list initialized from iterable's items | | Methods defined here: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in…
36.'int', 用于将一个字符串或数字转换为整型 class int(object) | int(x=0) -> integer | int(x, base=10) -> integer | | Convert a number or string to an integer, or return 0 if no arguments | are given. If x is a number, return x.__int__(). For floating point | numbers…
32.'help', 接收对象作为参数,更详细地返回该对象的所有属性和方法 class _Helper(builtins.object) | Define the builtin 'help'. | | This is a wrapper around pydoc.help that provides a helpful message | when 'help' is typed at the Python interactive prompt. | | Calling help() at t…
27.'frozenset', 返回一个冻结的集合,冻结后集合不能再添加或删除任何元素. class frozenset(object) | frozenset() -> empty frozenset object | frozenset(iterable) -> frozenset object | | Build an immutable unordered collection of unique elements. # 创建一个不可变得,无序的,元素唯一的集合 | | Methods…
25.'float', 用于将整数和字符串转换成浮点数. class float(object) | float(x) -> floating point number | | Convert a string or number to a floating point number, if possible. | | Methods defined here: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Retu…
17.'dict', 用于创建一个字典. class dict(object) | dict() -> new empty dictionary # 空字典 | dict(mapping) -> new dictionary initialized from a mapping object's | (key, value) pairs # dict([('one', 1), ('two', 2)]) | dict(iterable) -> new dictionary initiali…
11.'classmethod', 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象等. class classmethod(object) | classmethod(function) -> method | | Convert a function to be a class method. # 将一个函数转换成类方法 | | A class method receives the class as…
7.'bytearray', 返回一个新字节数组.这个数组里的元素是可变的,并且每个元素的值范围: 0 <= x < 256. class bytearray(object) | bytearray(iterable_of_ints) -> bytearray # 元素必须为[0 ,255] 中的整数 | bytearray(string, encoding[, errors]) -> bytearray # 按照指定的 encoding 将字符串转换为字节序列 | bytearr…
71.'zip' , 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表.如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表. class zip(object) | zip(iter1 [,iter2 [...]]) --> zip object | | Return a zip object whose .__next__() method returns a tuple where | th…
69.'type', 返回对象类型 class type(object) | type(object_or_name, bases, dict) | type(object) -> the object's type | type(name, bases, dict) -> a new type | | Methods defined here: | | __call__(self, /, *args, **kwargs) | Call self as a function. | | __de…
68.'tuple', 转换为元组类型 class tuple(object) | tuple() -> empty tuple | tuple(iterable) -> tuple initialized from iterable's items | | If the argument is a tuple, the return value is the same object. | | Methods defined here: | | __add__(self, value, /)…
62.'slice', 对序列化类型数据切片,返回一个新的对象. class slice(object) | slice(stop) | slice(start, stop[, step]) | | Create a slice object. This is used for extended slicing (e.g. a[0:10:2]). | | Methods defined here: | | __eq__(self, value, /) | Return self==value.…
58.'reversed',  返回一个反转的迭代器. class reversed(object) | reversed(sequence) -> reverse iterator over values of the sequence | | Return a reverse iterator | | Methods defined here: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __it…
56.'range',  创建一个整数列表 class range(object) | range(stop) -> range object | range(start, stop[, step]) -> range object | | Return an object that produces a sequence of integers from start (inclusive) | to stop (exclusive) by step. range(i, j) produces…
55.'property',  获取对象的所有属性 class property(object) | property(fget=None, fset=None, fdel=None, doc=None) -> property attribute | | fget is a function to be used for getting an attribute value, and likewise | fset is a function for setting, and fdel a f…
44.'map',  根据提供的函数对指定序列做映射. class map(object) | map(func, *iterables) --> map object | | Make an iterator that computes the function using arguments from | each of the iterables. Stops when the shortest iterable is exhausted. | | Methods defined here…
41.'license', 许可证,执照 class _Printer(builtins.object) | interactive prompt objects for printing the license text, a list of | contributors and the copyright notice. | | Methods defined here: | | __call__(self) | Call self as a function. | | __init__(s…
24.'filter', 用于过滤序列,过滤掉不符合条件的元素,返回由符合条件元素组成的新列表.该接收两个参数,第一个为函数,第二个为序列,序列的每个元素作为参数传递给函数进行判,然后返回 True 或 False,最后将返回 True 的元素放到新列表中. class filter(object) | filter(function or None, iterable) --> filter object | | Return an iterator yielding those items…
21.'enumerate', 用于将一个可遍历的数据对象(如列表.元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中. class enumerate(object) | enumerate(iterable[, start]) -> iterator for index, value of iterable # 返回一个索引和值的迭代器 | | Return an enumerate object. iterable must be another obje…
15.'credits', 信用 class _Printer(builtins.object) | interactive prompt objects for printing the license text, a list of | contributors and the copyright notice. | | Methods defined here: | | __call__(self) | Call self as a function. | | __init__(self,…
14.'copyright', 版权 class _Printer(builtins.object) | interactive prompt objects for printing the license text, a list of | contributors and the copyright notice. 交互式提示对象打印许可证信息,撰稿者列表,和版权说明 | | Methods defined here: | | __call__(self) | Call self as a…
13.'complex', 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数.如果第一个参数为字符串,则不需要指定第二个参数. class complex(object) | complex(real[, imag]) -> complex number | | Create a complex number from a real part and an optional imaginary part. | This is equivalent to (…
Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分.文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示.Python 3不会以任意隐式的方式混用str和bytes,,你不能拼接字符串和字节流,也无法在字节流里搜索字符串(反之亦然),也不能将字符串传入参数为字节流的函数(反之亦然).下面让我们深入分析一下二者的区别和联系. 一.字符编码 谈到Python3.x中bytes类型和str类型,就不得不先说说编码的事情. 在计算机历史的早期,美国为代表的英语…