简体   繁体   中英

How to run another python program

I already have

import os
exec(os.popen("Packman Game.py").read()

But it doesn't do anything and doesn't give me an error message What do I need to do?

PS:Without typing into the shell.

You can use os.system .

For example :

import os
os.system("myOtherPythonScript.py [parameters]")

Or you can also use subprocess :

    <!-- language: python -->
    import subprocess
    result = subprocess.check_output("Packman Game.py",shell=True) 

If you want to read the result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM