Python bytearray() လုပ်ဆောင်ချက်
ဥပမာ
4 bytes ၏ array တစ်ခုကို ပြန်ပေးသည်-
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. |