是否有使用“-m pdb”查看 python 文件是否为 运行 的函数?

Is there a function to see if the python file is run using "-m pdb"?

当我使用“-m pdb”时,某些代码无法正常运行。所以我想知道是否有办法查看文件是否 运行 使用“-m pdb”来选择与 运行 我的代码不同的方法。

您可以使用 :

进行测试
"pdb" in sys.modules