python函数 - bytearray
Oct 17, 2016 pm 03:34 PMbytearray([source [, encoding [, errors]]])
中文说明:
bytearray([source [, encoding [, errors]]])返回一个byte数组。Bytearray类型是一个可变的序列,并且序列中的元素的取值范围为 [0 ,255]。
参数source:
如果source为整数,则返回一个长度为source的初始化数组;
如果source为字符串,则按照指定的encoding将字符串转换为字节序列;
如果source为可迭代类型,则元素必须为[0 ,255]中的整数;
如果source为与buffer接口一致的对象,则此对象也可以被用于初始化bytearray.。
版本:在python2.6后新引入,在python3中同样可以使用!
英文说明:
Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0
The optional source parameter can be used to initialize the array in a few different ways:
If it is a string, you must also give the encoding (and optionally, errors) parameters; bytearray() then converts the string to bytes using str.encode().
If it is an integer, the array will have that size and will be initialized with null bytes.
If it is an object conforming to the buffer interface, a read-only buffer of the object will be used to initialize the bytes array.
If it is an iterable, it must be an iterable of integers in the range 0
Without an argument, an array of size 0 is created.
New in version 2.6.
实例演示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|

Article chaud

Outils chauds Tags

Article chaud

Tags d'article chaud

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Comment utiliser Python pour trouver la distribution ZIPF d'un fichier texte

Comment utiliser la belle soupe pour analyser HTML?

Comment effectuer l'apprentissage en profondeur avec TensorFlow ou Pytorch?

Introduction à la programmation parallèle et simultanée dans Python

Sérialisation et désérialisation des objets Python: partie 1

Comment implémenter votre propre structure de données dans Python

Modules mathématiques en python: statistiques
