我如何防止蟒蛇冻结工作在一个大的数字方程



因为计算A要花太多时间,所以我希望停止计算,让程序继续计算b。知道这是什么错误也会很有帮助。

A = 999999999999999999**999999999999999999
B = 9**9

当使用threading.Timer()

时程序仍然冻结
import threading
import time
a = 1
def zzz():
    global a
    print('restarting')
    a = 0
    threading.Timer(1.0,zzz).start()
    a = 1

threading.Timer(1.0, zzz).start()

while 1:
    while a == 1:
        h = 999999999999999**999999999999999

我相信问题已经解决了:添加"。在一个数字的末尾加上"0"将允许python识别出999999999999999999.0 ** 999999999999999999太大,并将输出一个可以用try/except

忽略的错误

最新更新