PTA的Python练习题(补)

题目要求我们实现进制的转换,当时做题只写出来一个实现两位数的

import math
a,b=map(int,input().split(','))
c=len(str(a))
d=e=f=0
g=a
for i in range(c):
        g-=f
        d=round(g/10**(c-i-1))
        f=d*(10**(c-i-1))
        e+=d*(b**(c-i-1))
print(e)
posted @ 2020-05-14 16:02  ch0bits  阅读(235)  评论(0编辑  收藏  举报