ktsangop 23 Junior Poster in Training

Try something like string formatting ...

myvalue = 16

command2 = r"\x03\xa2\x%02x" % myvalue

print command2  # \x03\xa2\x10

Does not work either
Print function "escapes" '\\' correctly
But if you type :

myvalue = 16

command2 = r"\x03\xa2\x%02x" % myvalue

# JUST OUTPUT THE STRING INSTEAD OF PRINTING IT
command2  #\\x03\\xa2\\x10