Python bytearray()関数
例
4バイトの配列を返します。
x = bytearray(4)
定義と使用法
このbytearray()
関数はbytearrayオブジェクトを返します。
オブジェクトをbytearrayオブジェクトに変換したり、指定したサイズの空のbytearrayオブジェクトを作成したりできます。
構文
bytearray(x, encoding, error)
パラメータ値
Parameter | Description |
---|---|
x | A source to use when creating the bytearray object. If it is an integer, an empty bytearray object of the specified size will be created. If it is a String, make sure you specify the encoding of the source. |
encoding | The encoding of the string |
error | Specifies what to do if the encoding fails. |