如何将("1,0,1,1,0,0,1,0")转换为基数10。我一直在寻找将列表转换为基数10的答案,但不是在我已经有了这个字符串的情况下
发布于 2015-03-18 04:36:17
您可以使用str.replace和int函数:
>>> s="1,0,1,1,0,0,1,0"
>>> int(s.replace(',',''),2)
178发布于 2015-03-18 15:15:27
或者,您可以切片:
int(string[::2], 2)https://stackoverflow.com/questions/29108235
复制相似问题