在 Python 或 F# 中运行带参数的批处理文件 [英] Running a batch file with parameters in Python OR F#

查看:18
本文介绍了在 Python 或 F# 中运行带参数的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了该网站,但没有看到任何与我要查找的内容完全匹配的内容.我创建了一个使用我创建的 Web 服务的独立应用程序.运行我使用的客户端:

I searched the site, but I didn't see anything quite matching what I was looking for. I created a stand-alone application that uses a web service I created. To run the client I use:

C:/scriptsdirecotry> "run-client.bat" param1 param2 param3 param4

我将如何使用 Python 或 F# 进行编码.看起来应该很简单,但我还没有在网上看到任何与我正在寻找的内容完全匹配的内容.

How would I go about coding this in Python or F#. It seems like it should be pretty simple, but I haven't seen anything online that quite matches what I'm looking for.

推荐答案

Python 类似.

import os
os.system("run-client.bat param1 param2")

如果您需要异步行为或重定向标准流.

If you need asynchronous behavior or redirected standard streams.

from subprocess import *
p = Popen(['run-client.bat', param1, param2], stdout=PIPE, stderr=PIPE)
output, errors = p.communicate()
p.wait() # wait for process to terminate

这篇关于在 Python 或 F# 中运行带参数的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆