ord(x)
returns the Unicode of x
.
Since Unicode is an extension of ASCII, ord
will also work for all things encoded by ASCII. Note that the returned value is in decimal. If you want it in another base, you can use
bin(ord(x))
oct(ord(x))
hex(ord(x))
as you see fit.