Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate strings with binary values in python?

What's the easiest way in python to concatenate string with binary values ?

sep = 0x1
data = ["abc","def","ghi","jkl"]

Looking for result data "abc0x1def0x1ghi0x1jkl" with the 0x1 being binary value not string "0x1".

like image 936
stefanB Avatar asked Dec 07 '22 07:12

stefanB


1 Answers

I think

joined = '\x01'.join(data) 

should do it. \x01 is the escape sequence for a byte with value 0x01.

like image 198
pdc Avatar answered Jan 02 '23 11:01

pdc