列表推导式求1000以内的质数

lis2 = [i for i in range(2, 1000)if 0 not in [i % j for j in range(2, int(i**0.5)+1)]]
print(lis2)

你可能感兴趣的:(python练习)