0

I need convert binary data to ASCII string. This string was packed as 15 bytes. For parsing other data in packet I use bitstring Python module. But I can't find functions for ASCII string unpack.

I get string data in binary format:

>> value = const_bit_stream.read(8*15)
>> str(value)
'0x383638323034303031353732383939'

How I can convert these bytes to ASCII string using bitstring or other tool?

1 Answer 1

1

Use binascii to convert binary to ASCII.

binascii.b2a_uu(data)

where data is a variable with a length of 45 or less characters. The return value is the converted value.

http://docs.python.org/2/library/binascii.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.