📜  二进制转十进制python代码示例

📅  最后修改于: 2022-03-11 14:45:10.867000             🧑  作者: Mango

代码示例5
def binary2int(binary): 
    int_val, i, n = 0, 0, 0
    while(binary != 0): 
        a = binary % 10
        int_val = int_val + a * pow(2, i) 
        binary = binary//10
        i += 1
    print(int_val) 
    

binary2int(101)