尝试打印Eratosthenes Siege。 我明白了:
AttributeError: 'function' object has no attribute 'primes'
代码:
def get_numbers(n):
primes = []
for i in range(0,n+1):
primes.append(i)
return primes
def erat(n):
max = int(sqrt(n+1)) + 1
list = get_numbers.primes
for i in range(n+1, max):
if i in list:
for j in range(2, max):
if list[i]%j == 0:
del list[i]
return list
print(erat(n = 10))