b = '1' c = len(b) while c < 9: d = b.ljust(8, '0') #两种输出格式 print( f"二进制{ d }相当于十进制{ int(d,2) }") print( "二进制%s相当于十进制%s" %(d, int(d,2))) b = b+'1' c = len(b)
标签:Python,IP,print,len,int,掩码 From: https://www.cnblogs.com/bravesunforever/p/17659853.html