SP/web2py/gluon/contrib/pymysql/util.py
Saturneic 064f602b1a Add.
2018-10-25 23:33:13 +08:00

23 lines
332 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)
def join_bytes(bs):
if len(bs) == 0:
return ""
else:
rv = bs[0]
for b in bs[1:]:
rv += b
return rv