import time
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n % i==0:
return False
else:
return True
strPrimes=""
t=time.clock()
for j in range(2,1000):
if isPrime(j):
strPrimes=strPrimes+str(j)+","
print(strPrimes)
print("Time used:{}".format(time.clock()-t))
运行结果如下: