Answers for "python byte size"

5

python file size

>>> import os
>>> b = os.path.getsize("/path/isa_005.mp3")
>>> b
2071611
Posted by: Guest on May-14-2020
0

Python bytes

>>> (1024).to_bytes(2, byteorder='big')
b'x04x00'
>>> (1024).to_bytes(10, byteorder='big')
b'x00x00x00x00x00x00x00x00x04x00'
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
b'xffxffxffxffxffxffxffxffxfcx00'
>>> x = 1000
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
b'xe8x03'
Posted by: Guest on January-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language