ฟังก์ชัน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. |