Built-in Functions and Types
ord()
Obtain the integer code point of a single Unicode character or the byte value of a one-byte bytes or bytearray object. The input must have length one; a multi-code-point grapheme may look like one character but is not accepted as a single input. This is not UTF-8 encoding.
Formal Syntax & Structure
python syntaxpython
ord(character, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| character | str | bytes | bytearray | Exactly one code point or byte. |
Return Value
int
Unicode code point, or an integer from 0 to 255 for a one-byte input.
Working Example
Example Snippetpython
print(ord("م"))print(ord(b"A"))