#!/usr/bin/env python #-*- coding: iso-8859-1 -*- def toString(zahl, base): werte = ('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') out = "" while (zahl > 0): rest = zahl % base out += werte[rest] zahl = zahl // base return out[::-1] def parseInt(str_, base): werte = ('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') wert = {} str_ = str_[::-1] val = "" back = 0 for x in range(36): wert[werte[x]] = x for x in range(len(str_)): val_ = str_[x:x + 1] back += wert[val_] * (base ** x) return back num = 12345 system_ = 36 string_ = toString(num, system_) print string_ zahl = parseInt(string_, system_) print zahl