0

I have the byte representation of a character in a string, let's say the character is 'H', which has the byte value of 72. My string is therefore "72".

How do I go about converting this string ("72") into its corresponding character value ('H') based on the byte value (72) represented in my string using python 3.6?

Psuedo code:

str = 72
print(decode_as_byte_value(str))

Expected result:

H

2 Answers 2

1
ord('H')
chr(72)

Its as simple as that. Remember that chr() only takes int and ord() only takes str

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

Comments

1

Please do not use this community for such Syntex based questions.

Still your ans is:

# Get the ASCII number of a character 
number = ord(char)

# Get the character given by an ASCII number
char = chr(number)

If this is your answer tick mark this response.

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.