代码:
1 import math 2 l = [x for x in range(1,101) if 0 not in [x%y for y in range(2,int(math.sqrt(x))+1)]] 3 print(len(l)) 4 print(l)
执行结果:
代码:
1 import math 2 l = [x for x in range(1,101) if 0 not in [x%y for y in range(2,int(math.sqrt(x))+1)]] 3 print(len(l)) 4 print(l)
执行结果: