The chr () function will have the effect of translating the variable into a string with the binary value you are looking for.
>>> sep = 0x1
>>> sepc = chr(sep)
>>> sepc
'\x01'
The join () function can then be used to concatenate a string of strings with your binary value as a separator.
>>> data = ['abc']*3
>>> data
['abc', 'abc', 'abc']
>>> sepc.join(data)
'abc\x01abc\x01abc'
source
share