求助
def Dec2Bin(dec):temp = []
while dec:
quo = dec % 2
dec = dec // 2
temp.append(quo)
return temp
print(Dec2Bin(62))
这个为什么返回的值是0,而不是011111 因为只循环了一次,碰到return 就退出函数了。 那在请问一下如果我想输出我要的011111结果该怎么改,我试了好多次都不行{:5_109:} 把 return 减少一个缩进就行了。
def Dec2Bin(dec):
temp = []
while dec:
quo = dec % 2
dec = dec // 2
temp.append(quo)
return temp
print(Dec2Bin(62)) 万分感谢!
页:
[1]