SyntaxFix
Write A Post
Hire A Developer
Questions
Just use a bytearray() which is a list of bytes.
bytearray()
Python2:
s = "ABCD" b = bytearray() b.extend(s)
Python3:
s = "ABCD" b = bytearray() b.extend(map(ord, s))
By the way, don't use str as a variable name since that is builtin.
str