How to get the ascii code of Chinese characters?

Fredrik Lundh fredrik at pythonware.com
Sun Aug 20 04:58:19 EDT 2006


many_years_after wrote:

> Well, people may input from keyboard. They input some Chinese
> characters, then, I want to create a number. The same number will be
> created if they input the same Chinese characters.

assuming you mean "code point" rather than "ASCII code" (ASCII is a 
specific encoding that *doesn't* include Chinese characters), "ord" is 
what you want:

    char = read_from_some_input_device()
    code = ord(char)

see:

    http://pyref.infogami.com/ord

</F>




More information about the Python-list mailing list