1、产生2进制下连续的1的情况
ls=[] for i in range(128,256): a=bin(i)[2:] ls1=''.join(a) for j in range(len(ls1)): if int(ls1[j]) == 0: ls2 = ls1[j:] sum = 0 for k in ls2: sum += int(k) if sum > 0: break else: ls.append(i) else: continue print(sorted(set(ls)))
2024-02-26 09:37:04
1、产生2进制下连续的1的情况
ls=[] for i in range(128,256): a=bin(i)[2:] ls1=''.join(a) for j in range(len(ls1)): if int(ls1[j]) == 0: ls2 = ls1[j:] sum = 0 for k in ls2: sum += int(k) if sum > 0: break else: ls.append(i) else: continue print(sorted(set(ls)))
下一篇:数据类型总结