发布网友 发布时间:2022-04-24 15:47
共1个回答
热心网友 时间:2023-10-20 11:27
def dec2bin(num):
l = []
if num < 0:
return '-' + dec2bin(abs(num))
while True:
num, remainder = divmod(num, 2)
l.append(str(remainder))
if num == 0:
return ''.join(l[::-1])
希望可以帮到你