#coding=gbk ''' 1、十进制转二进制 ''' num=int(input('请输入要转二进制的数字:')) result='' while 1: result+=str(num%2) num=num//2 if num==0: break print(result[::-1]) #二进制转回十进制 result_1=0 for i in range(len(result)): result_1+=int(result[i])*pow(2,i) print(result_1)