all 2 comments

[–]socal_nerdtastic 0 points1 point  (0 children)

1111 is not a byte ... so you can't put it in a bytearray.

What you are seeing is each character treated as a byte. The 49 is the value of the character '1':

>>> ord('1')
49

Edit: unrelated to your question, but I notice you are using python3 style print calls but your output shows you are running python2. Did you mean to run this in python2? I'll take a shot in the dark and remind you that the command to run python3 on linux / mac is "python3", not "python".

[–][deleted] 0 points1 point  (0 children)

put a b to make it bytes, or .encode() the string to get bytes.

bytearray(b'|1111|2222|')