On this page
ord
Prev: open | Up: __builtins__ | Next: pow
Rel: ascii, bin, chr, format, hex
Ref: docs.python.org — ord
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import ord
Overview & Signature
ord(character, /)
Return the ordinal value of a character.
Usage
assert ord("A") == 65
assert ord("€") == 0x20AC
Gotchas
- Single character only: Passing an empty string or 2+ characters raises
TypeError.
REPL Inspect
help(ord)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/open Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/pow Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/ascii Linked here; shared tags: #builtins
- tuts/python3/__builtins__/bin Linked here; shared tags: #builtins
- tuts/python3/__builtins__/chr Linked here; shared tags: #builtins
- tuts/python3/__builtins__/format Linked here; shared tags: #builtins
- tuts/python3/__builtins__/hex Linked here; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins