命令行跑python_怎么跑命令行.exe来自python的命令?

该内容描述了如何在编程中使用系统调用来执行命令,指出这种方式在不同操作系统上的行为差异。在Unix上,返回值是进程的退出状态,而在Windows上,返回值是系统 shell 执行命令后的结果。建议使用更强大的`subprocess`模块来替代此功能,并提供了相关模块的转换指南。
摘要由CSDN通过智能技术生成

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 sys.stdin, etc. are not reflected in

the environment of the executed command. If command generates any

output, it will be sent to the interpreter standard output stream.

On Unix, the return value is the exit status of the process encoded in

the format specified for wait(). Note that POSIX does not specify the

meaning of the return value of the C system() function, so the return

value of the Python function is system-dependent.

On Windows, the return value is that returned by the system shell

after running command. The shell is given by the Windows environment

variable COMSPEC: it is usually cmd.exe, which returns the exit status

of the command run; on systems using a non-native shell, consult your

shell documentation.

The subprocess module provides more powerful facilities for spawning

new processes and retrieving their results; using that module is

preferable to using this function. See the Replacing Older Functions

with the subprocess Module section in the subprocess documentation for

some helpful recipes.

Availability: Unix, Windows.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值