• windows
cmd=['start','python',"aa.py",param1]
work_dir=os.getcwd()+'/'
subprocess.Popen(cmd, cwd=work_dir, shell=True)
  • linux
cmds="python3 aa.py param1"
subprocess.Popen(cmds, shell=True)

执行cmd命令行获取返回结果

ret= subprocess.Popen(cmds, cwd=os.getcwd() + '/', shell=True,  stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8' )
        except Exception as ex:
            print("Exception:", ex)
print(ret.communicate()[0] )