递归实现 十进制转换其他进制(2-16)

1 def to_str(n, base):
2     convert_string = "0123456789ABCDEF"
3     if n < base:
4         return convert_string[n]
5     else:
6         return to_str(n / base, base) + convert_string[n % base]
7 
8 print to_str(168, 8)
原文地址:https://www.cnblogs.com/laresh/p/6550297.html