【发布时间】:2020-07-13 19:47:09
【问题描述】:
Traceback (most recent call last):
File "C:\Users\user\Desktop\modular inverse.py", line 12, in <module>
Multiples_of_e.append(e*f)
MemoryError
这是代码:
Multiples_of_e = []
e=input("Enter the exponent: ")
f=1
for i in range(100000):
Multiples_of_e.append(e*f)
f+=1
如果我删除这两行
e=input("Enter the exponent: ")
totent=input("Enter the totent: ")
我只是在问题得到解决的代码中用它的值替换每个变量,有没有办法让这个工作不这样做?
【问题讨论】:
-
问题显然出在第一个循环中,如错误消息所示。第二个循环无关紧要,将其从问题中删除。出于同样的原因,还要删除
totent=input("Enter the totent: ")和foundit=False。现在,您输入的e的值是多少? -
我通常输入的 e 的值是 65537,但即使它很大,只要我删除代码行 e=input("Enter the exponent: ")
-
如果你插入一个简单的
print命令来跟踪你的值,你会发现问题。
标签: python python-3.x memory out-of-memory