python allows conversions from string to integer using any base in the range [2,36] using:
int(string,base)
im looking for an elegant inver
numpy.base_repr is a quite good solution, however, in some cases, we want a fixed-length string with leading zeros.
numpy.base_repr
def base_repr(x: int, base: int, length: int): from numpy import base_repr from math import log, ceil s = base_repr(x, base, length - ceil(log(x, base))) return s