开发者

whats the easiest way of converting a character into its ascii equivalent in python? [duplicate]

开发者 https://www.devze.com 2023-02-09 11:50 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: 开发者_运维知识库ASCII value of a character in python
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

开发者_运维知识库 ASCII value of a character in python

The method I have applied is mapping the characters in an array . Is there a library for it ?


ord() — or are you asking for something entirely different?

Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string. … This is the inverse of chr() for 8-bit strings and of unichr() for unicode objects.


ord('a')

Displays the ascii value, assuming that's what you're asking. If you mean Unicode characters, then that's a bit more tricky - a mapping would be the best way to do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消