You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# test builtin ord (whether or not we support unicode)
|
|
|
|
|
|
|
|
print(ord('a'))
|
|
|
|
|
|
|
|
try:
|
|
|
|
ord('')
|
|
|
|
except TypeError:
|
|
|
|
print("TypeError")
|
|
|
|
|
|
|
|
# bytes also work in ord
|
|
|
|
|
|
|
|
print(ord(b'a'))
|
|
|
|
print(ord(b'\x00'))
|
|
|
|
print(ord(b'\x01'))
|
|
|
|
print(ord(b'\x7f'))
|
|
|
|
print(ord(b'\x80'))
|
|
|
|
print(ord(b'\xff'))
|
|
|
|
|
|
|
|
try:
|
|
|
|
ord(b'')
|
|
|
|
except TypeError:
|
|
|
|
print("TypeError")
|
|
|
|
|
|
|
|
# argument must be a string
|
|
|
|
try:
|
|
|
|
ord(1)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|