How can I encode an integer with base 36 in Python and then decode it again?
You can use numpy's base_repr(...) for this.
import numpy as np
num = 2017
num = np.base_repr(num, 36)
print(num) # 1K1
num = int(num, 36)
print(num) # 2017
Here is some information about numpy, int(x, base=10), and np.base_repr(number, base=2, padding=0).
(This answer was originally submitted as an edit to @christopher-beland's answer, but was rejected in favor of its own answer.)