14 lines
180 B
Python
14 lines
180 B
Python
import struct
|
|
|
|
|
|
def byte2int(b):
|
|
if isinstance(b, int):
|
|
return b
|
|
else:
|
|
return struct.unpack("!B", b)[0]
|
|
|
|
|
|
def int2byte(i):
|
|
return struct.pack("!B", i)
|
|
|