除二取余倒序排列

def Dec2Bin(dec):
    temp = []
    result = ''
    
    while dec:
        quo = dec % 2
        dec = dec // 2
        temp.append(quo)
 
    while temp:
        result += str(temp.pop())
    
    return result
 
print(Dec2Bin(62))

 

posted @ 2017-01-31 16:33  道高一尺  阅读(693)  评论(0编辑  收藏  举报