用divmod处理十进制转二进制很方便
def gc(n,k):
s = ''
while n:
n,f = divmod(n,k)
s = str(f) + s
return s
print(gc(789,2))
用divmod处理十进制转二进制很方便
def gc(n,k):
s = ''
while n:
n,f = divmod(n,k)
s = str(f) + s
return s
print(gc(789,2))