0

我有这个 python 脚本,它不会按照我想要的正确顺序运行。这是代码:

import VT as vt
import VT_Tests
import AUTO as auto


def main():
    auto.run()
    vt.run()

if __name__ == '__main__':
    main()

我希望它首先运行AUTO模块,但它只是先跳到另一个模块。

4

1 回答 1

1

The body of the module is executed in the import statement. Your problem is probably that you are VT_Tests is calling vt.run() in its body - it shouldn't. You should test for __name__ just like you did here before calling anything you don't want to be called upon import.

于 2013-06-14T12:56:57.873 回答