ScanSkill

ord

This ord() function returns an integer representing the code of the character.

Syntax

ord(character)

Here,

  • character: Required. String, any character.

Note: If a Unicode argument is given and Python was built with UCS2 Unicode, then the character’s code point must be in the range [0 to 65535] inclusive; otherwise the string length is two, and a TypeError will be raised.

Examples

  • With String
>>> ord('a')
97
>>> ord('A')
65
  • With Unicode argument
>>> ord(u'a')
97
>>> ord(u'\\u2020')
8224