Python实现求1-1000以内的素数时间:2024-03-06 19:16:23 def func(): for i in range(2,1000): # count表示被整除的次数 count = 0 for j in range(1,i+1): if i%j==0: count+=1 # count==2说明,该数字只能被1和它本身整除 if count==2: if i==j: print(i) func()