In Python, how can I represent an integer value (<256) as a string? For example:
i = 10
How can I create a string "s" that is one-byte long, and the byte has the value 10?
to clarify, I do not want a string "10". I want a string that its 1st (and only) byte has the value of 10.
by the way, I cannot create the string statically:
s = '\x0A'
because the value is not pre-defined. It is a dynamic number value.
'\xA'is a syntax error, presumably you meant'\x0A'.