7、'bytearray', 返回一个新字节数组。这个数组里的元素是可变的,并且每个元素的值范围: 0 <= x < 256。

class bytearray(object)
| bytearray(iterable_of_ints) -> bytearray
# 元素必须为[0 ,255] 中的整数
| bytearray(string, encoding[, errors]) -> bytearray
# 按照指定的 encoding 将字符串转换为字节序列
| bytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer
# 字节流
| bytearray(int) -> bytes array of size given by the parameter initialized with null bytes
# 返回一个长度为 source 的初始化数组
| bytearray() -> empty bytes array
# 默认就是初始化数组为0个元素
|
| Construct a mutable bytearray object from:
| - an iterable yielding integers in range(256) # bytearray([1, 2, 3])
| - a text string encoded using the specified encoding # bytearray('你妈嗨', encoding='utf-8')
| - a bytes or a buffer object # bytearray('你妈嗨'.encode('utf-8'))
| - any object implementing the buffer API. #
| - an integer # bytearray(10)
|
| Methods defined here:
|
| __add__(self, value, /)
| Return self+value.
|
| __alloc__(...)
| B.__alloc__() -> int
|
| Return the number of bytes actually allocated.
|
| __contains__(self, key, /)
| Return key in self.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __iadd__(self, value, /)
| Implement self+=value.
|
| __imul__(self, value, /)
| Implement self*=value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.n
|
| __ne__(self, value, /)
| Return self!=value.
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __reduce__(self, /)
| Return state information for pickling.
|
| __reduce_ex__(self, proto=0, /)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return self*value.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(self, /)
| Returns the size of the bytearray object in memory, in bytes.
|
| __str__(self, /)
| Return str(self).
|
| append(self, item, /)
| Append a single item to the end of the bytearray.
|
| item
| The item to be appended.
|
| capitalize(...)
| B.capitalize() -> copy of B
|
| Return a copy of B with only its first character capitalized (ASCII)
| and the rest lower-cased.
|
| center(...)
| B.center(width[, fillchar]) -> copy of B
|
| Return B centered in a string of length width. Padding is
| done using the specified fill character (default is a space).
|
| clear(self, /)
| Remove all items from the bytearray.
|
| copy(self, /)
| Return a copy of B.
|
| count(...)
| B.count(sub[, start[, end]]) -> int
|
| Return the number of non-overlapping occurrences of subsection sub in
| bytes B[start:end]. Optional arguments start and end are interpreted
| as in slice notation.
|
| decode(self, /, encoding='utf-8', errors='strict')
| Decode the bytearray using the codec registered for encoding.
|
| encoding
| The encoding with which to decode the bytearray.
| errors
| The error handling scheme to use for the handling of decoding errors.
| The default is 'strict' meaning that decoding errors raise a
| UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
| as well as any other name registered with codecs.register_error that
| can handle UnicodeDecodeErrors.
|
| endswith(...)
| B.endswith(suffix[, start[, end]]) -> bool
|
| Return True if B ends with the specified suffix, False otherwise.
| With optional start, test B beginning at that position.
| With optional end, stop comparing B at that position.
| suffix can also be a tuple of bytes to try.
|
| expandtabs(...)
| B.expandtabs(tabsize=8) -> copy of B
|
| Return a copy of B where all tab characters are expanded using spaces.
| If tabsize is not given, a tab size of 8 characters is assumed.
|
| extend(self, iterable_of_ints, /)
| Append all the items from the iterator or sequence to the end of the bytearray.
|
| iterable_of_ints
| The iterable of items to append.
|
| find(...)
| B.find(sub[, start[, end]]) -> int
|
| Return the lowest index in B where subsection sub is found,
| such that sub is contained within B[start,end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| fromhex(string, /) from builtins.type
| Create a bytearray object from a string of hexadecimal numbers.
|
| Spaces between two numbers are accepted.
| Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')
|
| hex(...)
| B.hex() -> string
|
| Create a string of hexadecimal numbers from a bytearray object.
| Example: bytearray([0xb9, 0x01, 0xef]).hex() -> 'b901ef'.
|
| index(...)
| B.index(sub[, start[, end]]) -> int
|
| Return the lowest index in B where subsection sub is found,
| such that sub is contained within B[start,end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raises ValueError when the subsection is not found.
|
| insert(self, index, item, /)
| Insert a single item into the bytearray before the given index.
|
| index
| The index where the value is to be inserted.
| item
| The item to be inserted.
|
| isalnum(...)
| B.isalnum() -> bool
|
| Return True if all characters in B are alphanumeric
| and there is at least one character in B, False otherwise.
|
| isalpha(...)
| B.isalpha() -> bool
|
| Return True if all characters in B are alphabetic
| and there is at least one character in B, False otherwise.
|
| isdigit(...)
| B.isdigit() -> bool
|
| Return True if all characters in B are digits
| and there is at least one character in B, False otherwise.
|
| islower(...)
| B.islower() -> bool
|
| Return True if all cased characters in B are lowercase and there is
| at least one cased character in B, False otherwise.
|
| isspace(...)
| B.isspace() -> bool
|
| Return True if all characters in B are whitespace
| and there is at least one character in B, False otherwise.
|
| istitle(...)
| B.istitle() -> bool
|
| Return True if B is a titlecased string and there is at least one
| character in B, i.e. uppercase characters may only follow uncased
| characters and lowercase characters only cased ones. Return False
| otherwise.
|
| isupper(...)
| B.isupper() -> bool
|
| Return True if all cased characters in B are uppercase and there is
| at least one cased character in B, False otherwise.
|
| join(self, iterable_of_bytes, /)
| Concatenate any number of bytes/bytearray objects.
|
| The bytearray whose method is called is inserted in between each pair.
|
| The result is returned as a new bytearray object.
|
| ljust(...)
| B.ljust(width[, fillchar]) -> copy of B
|
| Return B left justified in a string of length width. Padding is
| done using the specified fill character (default is a space).
|
| lower(...)
| B.lower() -> copy of B
|
| Return a copy of B with all ASCII characters converted to lowercase.
|
| lstrip(self, bytes=None, /)
| Strip leading bytes contained in the argument.
|
| If the argument is omitted or None, strip leading ASCII whitespace.
|
| partition(self, sep, /)
| Partition the bytearray into three parts using the given separator.
|
| This will search for the separator sep in the bytearray. If the separator is
| found, returns a 3-tuple containing the part before the separator, the
| separator itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing the original
| bytearray object and two empty bytearray objects.
|
| pop(self, index=-1, /)
| Remove and return a single item from B.
|
| index
| The index from where to remove the item.
| -1 (the default value) means remove the last item.
|
| If no index argument is given, will pop the last item.
|
| remove(self, value, /)
| Remove the first occurrence of a value in the bytearray.
|
| value
| The value to remove.
|
| replace(self, old, new, count=-1, /)
| Return a copy with all occurrences of substring old replaced by new.
|
| count
| Maximum number of occurrences to replace.
| -1 (the default value) means replace all occurrences.
|
| If the optional argument count is given, only the first count occurrences are
| replaced.
|
| reverse(self, /)
| Reverse the order of the values in B in place.
|
| rfind(...)
| B.rfind(sub[, start[, end]]) -> int
|
| Return the highest index in B where subsection sub is found,
| such that sub is contained within B[start,end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| rindex(...)
| B.rindex(sub[, start[, end]]) -> int
|
| Return the highest index in B where subsection sub is found,
| such that sub is contained within B[start,end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raise ValueError when the subsection is not found.
|
| rjust(...)
| B.rjust(width[, fillchar]) -> copy of B
|
| Return B right justified in a string of length width. Padding is
| done using the specified fill character (default is a space)
|
| rpartition(self, sep, /)
| Partition the bytes into three parts using the given separator.
|
| This will search for the separator sep in the bytearray, starting and the end.
| If the separator is found, returns a 3-tuple containing the part before the
| separator, the separator itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing two empty bytearray
| objects and the original bytearray object.
|
| rsplit(self, /, sep=None, maxsplit=-1)
| Return a list of the sections in the bytearray, using sep as the delimiter.
|
| sep
| The delimiter according which to split the bytearray.
| None (the default value) means split on ASCII whitespace characters
| (space, tab, return, newline, formfeed, vertical tab).
| maxsplit
| Maximum number of splits to do.
| -1 (the default value) means no limit.
|
| Splitting is done starting at the end of the bytearray and working to the front.
|
| rstrip(self, bytes=None, /)
| Strip trailing bytes contained in the argument.
|
| If the argument is omitted or None, strip trailing ASCII whitespace.
|
| split(self, /, sep=None, maxsplit=-1)
| Return a list of the sections in the bytearray, using sep as the delimiter.
|
| sep
| The delimiter according which to split the bytearray.
| None (the default value) means split on ASCII whitespace characters
| (space, tab, return, newline, formfeed, vertical tab).
| maxsplit
| Maximum number of splits to do.
| -1 (the default value) means no limit.
|
| splitlines(self, /, keepends=False)
| Return a list of the lines in the bytearray, breaking at line boundaries.
|
| Line breaks are not included in the resulting list unless keepends is given and
| true.
|
| startswith(...)
| B.startswith(prefix[, start[, end]]) -> bool
|
| Return True if B starts with the specified prefix, False otherwise.
| With optional start, test B beginning at that position.
| With optional end, stop comparing B at that position.
| prefix can also be a tuple of bytes to try.
|
| strip(self, bytes=None, /)
| Strip leading and trailing bytes contained in the argument.
|
| If the argument is omitted or None, strip leading and trailing ASCII whitespace.
|
| swapcase(...)
| B.swapcase() -> copy of B
|
| Return a copy of B with uppercase ASCII characters converted
| to lowercase ASCII and vice versa.
|
| title(...)
| B.title() -> copy of B
|
| Return a titlecased version of B, i.e. ASCII words start with uppercase
| characters, all remaining cased characters have lowercase.
|
| translate(self, table, /, delete=b'')
| Return a copy with each character mapped by the given translation table.
|
| table
| Translation table, which must be a bytes object of length 256.
|
| All characters occurring in the optional argument delete are removed.
| The remaining characters are mapped through the given translation table.
|
| upper(...)
| B.upper() -> copy of B
|
| Return a copy of B with all ASCII characters converted to uppercase.
|
| zfill(...)
| B.zfill(width) -> copy of B
|
| Pad a numeric string B with zeros on the left, to fill a field
| of the specified width. B is never truncated.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| maketrans(frm, to, /)
| Return a translation table useable for the bytes or bytearray translate method.
|
| The returned table will be one where each byte in frm is mapped to the byte at
| the same position in to.
|
| The bytes objects frm and to must be of the same length.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None

python __builtins__ bytearray类 (7)的更多相关文章

  1. python __builtins__ bool类 (6)

    6.'bool',  函数用于将给定参数转换为布尔类型,如果没有参数,返回 False. class bool(int) # 继承于int类型 | bool(x) -> bool # 创建boo ...

  2. python __builtins__ staticmethod类 (64)

    64.'staticmethod', 返回静态方法 class staticmethod(object) | staticmethod(function) -> method | | Conve ...

  3. python __builtins__ memoryview类 (46)

    46.'memoryview',  返回给定参数的内存查看对象(Momory view).所谓内存查看对象,是指对支持缓冲区协议的数据进行包装,在不需要复制对象基础上允许Python代码访问. cla ...

  4. python __builtins__ int类 (36)

    36.'int', 用于将一个字符串或数字转换为整型 class int(object) | int(x=0) -> integer | int(x, base=10) -> intege ...

  5. python __builtins__ help类 (32)

    32.'help', 接收对象作为参数,更详细地返回该对象的所有属性和方法 class _Helper(builtins.object) | Define the builtin 'help'. | ...

  6. python __builtins__ float类 (25)

    25.'float', 用于将整数和字符串转换成浮点数. class float(object) | float(x) -> floating point number | | Convert ...

  7. python __builtins__ classmethod类 (11)

    11.'classmethod', 修饰符对应的函数不需要实例化,不需要 self 参数,但第一个参数需要是表示自身类的 cls 参数,可以来调用类的属性,类的方法,实例化对象等. class cla ...

  8. python __builtins__ bytes类 (8)

    8.'bytes', 字符串转换成字节流.第一个传入参数是要转换的字符串,第二个参数按什么编码转换为字节. class bytes(object) | bytes(iterable_of_ints) ...

  9. python __builtins__ zip类 (71)

    71.'zip' , 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表.如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作 ...

随机推荐

  1. 按字节寻址and按字编址

    按字节寻址,存储空间的最小编址单位是字节,按字编址,存储空间的最小编址单位是字,最小编址单位的选择,和存储容量.地址总线宽度都有关联 .同样的存储容量, 粒度小了,地址长度就需要更长 .就是根据不同的 ...

  2. 简谈Java的join()方法(转)

    join()是Thread类的一个方法.根据jdk文档的定义: public final void join()throws InterruptedException: Waits for this ...

  3. HDOJ 1217 Arbitrage(拟最短路,floyd算法)

    Arbitrage Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  4. Oracle创建JOB定时任务

    --- DECLARE JOB NUMBER;BEGIN      DBMS_JOB.SUBMIT(          JOB=>JOB,          WHAT=>'CTABLE_T ...

  5. npm的安装和更新

    https://nodejs.org官网下载软件安装 验证是否安装,进入命令行 输入npm -v 这个是安装node自动带的工具 npm install npm@xxx 自动更新自己,后边跟版本号 n ...

  6. 对FreeMarker技术的思考

    依照静态非静态来划分网页分为两种:静态网页和非静态网页,究其优缺点而言,静态网页在用户訪问的时候响应快,可是因为里面的数据是写死的.所以致命的缺陷就是数据不能动态显示.非静态页面(如jsp)数据能够动 ...

  7. ln mv 发挥一个物体的元作用

    # tar xf ~/tools/mongodb-linux-x86_64-3.4.0.tgz -C /usr/local/; ln -sf /usr/local/mongodb-linux-x86_ ...

  8. Struts2的工作原理(图解)详解

    Struts2的工作原理 上图来源于Struts2官方站点,是Struts 2 的整体结构. 一个请求在Struts2框架中的处理大概分为以下几个步骤(可查看源码:https://github.com ...

  9. 关于在PHP中当一个请求未完成时,再发起另一个请求被阻塞的问题

    最近做项目的时候遇到个问题,就是做阿里云oss大文件上传进度条显示,因为要实时查询上传分片进度,所以在上传的同时必须要再发起查询的请求,但是一直都是所有分片上传完成后查询的请求才执行,刚开始以为是阿里 ...

  10. ie下文件上传无权访问的问题

    最近项目遇到个问题,ie下文件上传无权访问,在网上找了很久才找到答案,原来是因为ie下不能用js触发input=file的点击事件,必须手动点击才可以.