Thursday, July 21, 2022

[FIXED] How can I convert a character to a integer in Python, and viceversa?

Issue

I want to get, given a character, its ASCII value.

For example, for the character a, I want to get 97, and vice versa.


Solution

Use chr() and ord():

>>> chr(97)
'a'
>>> ord('a')
97


Answered By - Adam Rosenfield
Answer Checked By - Cary Denson (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.