【python】二进制转换

来源:互联网 发布:da8da六爻排盘软件 编辑:程序博客网 时间:2024/05/21 00:18
def convert_binary(num):    result = []    if num <= 1:        result.append(num)    else:        while True:            consult = num / 2            reminder = num % 2            result.append(reminder)            if consult == 1:               result.append(consult)               break            num = consult    return int("".join(map(str,result)))


原创粉丝点击