Skip to content

Tag: binary

Reading binary lines not matching file lines after first line

I’m trying to read and print the binary data of a file but notice after reading the first line, with 128 bits, the subsequent lines printed out do not match the lines when I look at the binary data manually with notepad++. Answer The problem is that when dc==16 then your program prints whole line but th…

how to convert bytes to binary using python

so i want convert bytes to binary in python, but when i run it, there’s none in the result and i got error: ‘NoneType’ object is not iterable here’s the code i tried Answer Your function currently returns None because there’s no return statement. Perhaps instead of using print, y…

What are these symbols in ‘bytes’ type?

So, I have a single byte in bytes format looking something like that: It is quite easy to understand that a single byte is the two symbols(0-F) after ‘x’ But sometimes the pattern doesn’t match, containing more than two symbols after ‘x’. So, for example, if I use secrets.token_b…

Data type somehow gets converted when appended to a list

I am trying to convert text to binary using ASCII encoding, and then decode the binary back to text as proof of concept for a larger project. The following code works well and does what it is supposed to do: However, as soon as I try to append the given value of output_data to a list within the for loop,

how can I split the elements of a list of binary numbers?

I’m trying to split the elements of a list of binary numbers as follows : bin_list=[‘000101111000′,’011110111011’] Expected result: bin_list=[[0,0,0,1,0,1,1,1,1,0,0,0],[0,1,1,1,1,0,1,1,1,0,1,1]] I think that would be a list of a list of integers what I’m trying to get?? I t…