Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个脚本——script1.py 和 script2.py。现在我想在 script2.py 中调用 script1.py。算法会是这样的——
IF 条件:运行 script1.py #通过命令行 ELSE:退出
到位script1.py:
script1.py
def main(): do something if __name__ == "__main__": main()
在script2.py:
script2.py
import script1 if condition: script1.main()