I want to pack a hex string with python pack.
Here is my code:
q= ('%x' % int(query, 16)).decode('hex').decode('utf-8')
The string gets truncated because you're telling it you want to pack it up to length 6 (
6s). You'll have to either raise that number, or work around your string getting truncated.
Also, stop juggling with the encoding of your string, just
query.decode('hex') should suffice.