-1
我需要转换的数基座10 我的输入是来自这种形式:1111(数)5(其上基部)10(到基站).I写了这个代码:我该如何与指数相乘?
s=input()
(number, from_base, to_base) = s.split()
NumList=[number]
NumList.reverse()
i=0
sum=0
while (i< (index.from_base)):
(i,pow(from_base,i),i+1)
sum=sum+i
print (sum)
我想要做的事:number^from_base index.I也试着做我从from_base \ i ^^ from_base。 我也尝试添加命令NumList.index(),但它没有工作。
谢谢!
实际上,你可以使用'int'功能做http://docs.python.org/2/library/functions.html#int在需要时采取额外的基础参数。 – soulseekah
@soulseekah ...如果“基地”总是10,那对吗? – BorrajaX
@BorrajaX,虽然OP的代码确实提到'to_base',所以... – soulseekah