我正在尝试找出如何在Databricks中的异常消息中获取实际的文件/模块名称。
import traceback
def bad():
print("hello")
a = 1/0
def main():
try:
bad()
except Exception as e:
print(traceback.format_exc())
main()
运行此异常消息时,我会收到-
hello
Traceback (most recent call last):
File "<command-162594828857243>", line 8, in main
bad()
File "<command-162594828857243>", line 4, in bad
a = 1/0
ZeroDivisionError: division by zero
"<command-162594828857243>"
在调试时无济于事。我想要那里的实际文件/模块名称。