Python bytes() လုပ်ဆောင်ချက်
ဥပမာ
4 bytes ၏ array တစ်ခုကို ပြန်ပေးသည်-
x = bytes(4)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
bytes()
လုပ်ဆောင်ချက်သည် bytes အရာဝတ္ထုတစ်ခုကို ပြန်ပေးသည် ။
၎င်းသည် အရာဝတ္တုများကို bytes အရာဝတ္ထုများအဖြစ်သို့ ပြောင်းလဲနိုင်သည်၊ သို့မဟုတ် သတ်မှတ်ထားသောအရွယ်အစား၏ ဗလာဘိုက်အရာဝတ္ထုကို ဖန်တီးနိုင်သည်။
bytes()
နှင့်
အကြား ကွာခြားချက်မှာ bytearray()
ပြုပြင်
bytes()
မွမ်းမံနိုင်သော အရာတစ်ခုကို ပြန်ပို့ပေးပြီး ပြုပြင်နိုင်သော
bytearray()
အရာတစ်ခုကို ပြန်ပေးခြင်းဖြစ်သည်။
အထားအသို
bytes(x, encoding, error)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
x | A source to use when creating the bytes object. If it is an integer, an empty bytes 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. |