from math import pow, log def convert(n,a,b): n=str(n) " n est un str, a et b des entiers " chiffres = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] nb_decimal = 0 i = len(n)-1 for x in n: nb_decimal += chiffres.index(x)*int(pow(a,i)) i= i-1 nbr_chars = int(log(nb_decimal)/log(b)+1) res = "" for i in range(0, nbr_chars): x = int(nb_decimal / pow(b,nbr_chars-1-i)) nb_decimal -= int(x * pow(b,nbr_chars-1-i)) res = res+chiffres[x] return res