main
Last change
on this file was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
332 bytes
|
Line | |
---|
1 | import struct |
---|
2 | |
---|
3 | |
---|
4 | def byte2int(b): |
---|
5 | if isinstance(b, int): |
---|
6 | return b |
---|
7 | else: |
---|
8 | return struct.unpack("!B", b)[0] |
---|
9 | |
---|
10 | |
---|
11 | def int2byte(i): |
---|
12 | return struct.pack("!B", i) |
---|
13 | |
---|
14 | |
---|
15 | def join_bytes(bs): |
---|
16 | if len(bs) == 0: |
---|
17 | return "" |
---|
18 | else: |
---|
19 | rv = bs[0] |
---|
20 | for b in bs[1:]: |
---|
21 | rv += b |
---|
22 | return rv |
---|
Note: See
TracBrowser
for help on using the repository browser.