错误跟踪使用EXEC打开多个文件时(Files(Files,' rb')。read())

发布于 2025-02-09 02:56:08 字数 417 浏览 1 评论 0原文

我正在使用以下代码一次运行多个.py文件。 这些文件都非常具体,很容易更改。因此,我更容易个性化它们,这样我就可以在需要时更改它们。

calculate=(
    'indicator1.py',
    'indicator2.py',
    'indicator3.py',
    'indicator4.py',
    'indicator5.py',
    'indicator6.py',
    'indicator7.py')

for file in calculate:
    exec(open(file,'rb').read())

当我遇到错误时出现问题。我无法立即知道哪个文件有问题。

如何添加一些从计算找到错误的代码行?如果可能的话,也在该特定文件的哪一行中。

太感谢了!

I'm using the following code to run multiple .py files at once.
The files are all very specific and prone to change very often. So it's easier for me to individualise them so I can change them whenever I need to.

calculate=(
    'indicator1.py',
    'indicator2.py',
    'indicator3.py',
    'indicator4.py',
    'indicator5.py',
    'indicator6.py',
    'indicator7.py')

for file in calculate:
    exec(open(file,'rb').read())

The problem arises when I get an error. I have no way to immediately know which file has the problem.

How can I add some lines of code that return the specific file from calculate where the error was found? If possible, also in which line of that specific file.

Thank you so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文