دالة 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. |