Subtract 256 if above 127:
unsigned = ord(character) signed = unsigned - 256 if unsigned > 127 else unsigned
As an alternative, repack bytes using the struct module:
from struct import pack, unpack signed = unpack('B', pack('b', unsigned))[0]
or directly from the symbol:
signed = unpack('B', character)[0]
source share