0

我正在尝试制作一个代码运行器,例如:如何使用 Brython 创建一个简单的 python 代码运行器

import traceback
try:
    code = "s"
    exec(code)  #should throw error s is not defined

except Exception as e:
    print('Error:', e)
    try:
        print(str(traceback.format_exc()))
    except Exception as err:
        print(err)

traceback.format_exc() 抛出异常:

'str' object cannot be interpreted as an integer

我的 Brython 版本是 3.9.5

4

0 回答 0