Skip to content Skip to sidebar Skip to footer

Decoding Url Encoded Byte Stream Data In Python

I'm receiving STX ETX packet data, here's a sample: The data has been URL encoded. Before it is encoded and sent it is like this: The relationship between the URL encoded data an

Solution 1:

You can use the urlparse module to decode that string.

importurlparsedata="/type=stxetx&packet=A%d93HX%01%00&serial=1234&foo=bar"

new_data = dict(urlparse.parse_qsl(data))

assertlen(new_data['packet']) == 7assert new_data['packet'][0] == 'A'assertord(new_data['packet'][1]) == 0xd9

Reference:

Post a Comment for "Decoding Url Encoded Byte Stream Data In Python"