I have a hex string like:
data = "437c2123"
I want to convert this string to a sequence of characters according to the ASCII table.
The result should be like:
data_con = "C|!#"
Can anyone tell me how to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here:
for i in range(0, len(data), 2)iterates over every second position indata:0,2,4etc.data[i:i+2]looks at every pair of hex digits'43','7c', etc.chr(int(..., 16))converts the pair of hex digits into the corresponding character.''.join(...)merges the characters into a single string.