Каков быстрый и простой способ упаковки знаковых значений в 4 бита? [закрыто]Python

Программы на Python
Гость
Каков быстрый и простой способ упаковки знаковых значений в 4 бита? [закрыто]

Сообщение Гость »


I have a python list of integers, each being in the range [-8,7]. I want to pack these values into an array of bytes that i will send down a socket connection. Since these values can be represented by 4 bits in a two's complement representation, it should be possible to pack two such values in each byte. What is a good and relatively fast way of doing this in python? Thanks


Источник: https://stackoverflow.com/questions/781 ... -in-4-bits

Вернуться в «Python»