通过Python执行Java程序 [英] Executing Java programs through Python
问题描述
我该怎么做?
推荐答案
你可以用 os.system()
function。
You can execute anything you want from Python with the os.system()
function.
os.system(command)
执行命令
(a子shell中的字符串)。这是通过调用Standard C
函数系统实现的
,并且具有相同的
限制。 os.environ,
sys.stdin等的更改未反映在
执行的
命令的环境中。
os.system(command)
Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system, and has the same limitations. Changes to os.environ, sys.stdin, etc. are not reflected in the environment of the executed command.
为了获得更多的功能和灵活性,您需要查看 子流程
模块:
For more power and flexibility you will want to look at the subprocess
module:
子流程模块允许你
产生新进程,连接到他们的
输入/输出/错误管道,并获得
他们的返回代码。
The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
这篇关于通过Python执行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!