I am trying to translate code from php to python. I have a list of binary literals –
['0b0', '0b0', '0b0', '0b0', '0b0', '0b0', '0b100', '0b1001100']
This is equal to 0000000000000000000000000000000000000000000000000000010001001100 when concatenated.
int("0000000000000000000000000000000000000000000000000000010001001100",2)
gives 1100
How do i make this from the list. Unable to concatenate binary literals.
Python understand
0b0101as a binary literal, so I useint('0b0101', 0)to convert each piece to an int. Then I format it in a convenient format (two digits of hex), concatenate them, and interpret them as a hex integer.