Created
May 5, 2019 11:02
-
-
Save hergerr/146efcd01bcf4c53b78579b7b9741b55 to your computer and use it in GitHub Desktop.
Bytearray to list of lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dec_to_bin(lst): | |
bin_matrix = [] | |
# kazda wartosc ma nowy wiersz w macierzy | |
for i in lst: | |
bin_matrix.append(list(bin(i)[2:])) | |
bin_matrix_int = [list(map(int, x)) for x in bin_matrix] | |
return bin_matrix_int | |
def bin_to_dec(bin_matrix): | |
dec_list = [] | |
for bin_list in bin_matrix: | |
temp = [str(bin_element) for bin_element in bin_list] | |
temp = ''.join(temp) | |
dec_list.append(temp) | |
return [int(number, 2) for number in dec_list] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment