How do I concatenate binary data using Python3
Oct 07, 2020
asked by anonymous
Question / Issue:
I want to take two variables that hold binary data and cat them together. For example, var1=0x0102 and var2=0x0304. How can I create a binary representation algorithmically using Python3?
Responses:
Date: Oct. 7, 2020
Author: Mind Chasers
Comment:
>>> var1=b'\x01\x02'
>>> var2=b'\x03\x04'
>>> var1+var2
b'\x01\x02\x03\x04'
>>> (var1+var2).hex()
'01020304'