看起来两种异常在类似的情况下都会被触发。
这两行代码背后发生了什么,它们之间有什么区别?
>>> (i for i in range(1000000000)) # 10^9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError
>>> (i for i in range(10000000000)) # 10^10
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: range() result has too many items