Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # paulogp
- def ConvertBinaryStringIntoByteList(texto):
- comprimento = len(texto)
- Lista = []
- byte = 0
- bits = 0
- for i in range(0,comprimento):
- byte = (byte<<1) | int(texto[i])
- if bits<7:
- bits = bits + 1
- else:
- Lista.append(byte)
- byte = 0
- bits = 0
- if bits!=0:
- Lista.append(byte<<(8-bits))
- return Lista
- # exemplo
- print(ConvertBinaryStringIntoByteList('1024'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement