ord() Character to code point
Last updated: 2026-09-22
ord() Character to code point
ord(c) returns the Unicode code point of single character c.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
ord(c)
⚙️ Parameters
| c Required | A string of exactly one character. |
|---|
Returns:The Unicode code point of the character as an int.
💥 Raises
TypeError— Raised when c is not a string.ValueError— Raised when c is not exactly one character.
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
65
20013
8364
🏷️ Related Built-in Functions
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does ord('A') return?
AIt returns 65, the Unicode codepoint of 'A'.
QWhat happens with ord('中文')?
AIt raises ValueError: ord() expected a character, but string of length 2 found — ord() accepts exactly one character.
QWhat is the relationship between ord() and chr()?
AThey are inverse operations: chr(ord('中')) == '中' and ord(chr(97)) == 97.
QDoes ord() support Chinese characters?
AYes — ord('中') returns 20013. Unicode codepoints apply to characters of any language, not just ASCII.