if number < 0:
    raise ValueError('number must be positive')
alphabet, base36 = ['0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '']
while number:
    number, i = divmod(number, 36)
base36 = alphabet[i] + base36
return base36 or alphabet[0]

def base36decode(number):
    return int(number, 36)
print(base36encode(1412823931503067241))
print(base36decode('AQF8AA0006EH'))
Python base 36 encoding