Python执行cmd命令
来源:互联网 发布:武威免费制作seo 编辑:程序博客网 时间:2024/05/22 12:08
需求:
需要在python的脚本中运行ffmpeg命令。比如需要执行以下命令: ffmpeg -i test hello.mp4 test hello.flv
如果使用os.system命令,传递进去就是os.system("ffmpeg -i test hello.mp4 test hello.flv"),注意,文件名中有空格,os.system()还是用空格把字符串给拆成了不同的部分,然后再调用shell来执行。
参考博客:http://blog.csdn.net/harbinzju/article/details/7857229
查看os.system文档:
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 sys.stdin, etc. are not reflected in the environment of the executed command.
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, given by the Windows environment variable COMSPEC: on command.com systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is 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.
官方是建议我们使用subprocess.Popen()来代替os.system(),先mark,继续学习中。
- Python执行cmd命令
- python下执行cmd命令
- python——执行cmd命令
- Python Windows 执行cmd命令(popen)
- cmd 命令执行 cmd 参数
- VC执行CMD命令
- qt执行cmd命令
- windows 执行CMD命令
- .Net执行cmd命令
- java执行cmd命令
- java 执行 cmd 命令
- cmd命令执行mysql
- C# 执行CMD命令
- java执行CMD命令
- cmd命令无法执行
- java 执行 cmd 命令
- java执行cmd命令
- 执行cmd命令
- android流媒体框架介绍
- PHP Base
- virtualbox 安装 虚拟系统
- JDK5.0中JVM堆模型、GC垃圾收集详细解析 .
- 巧用数据库SQL语句的“连接查询”功能
- Python执行cmd命令
- Java线程面试题Top50
- Java中堆、栈、常量池等概念解析
- mos管做开关的一些实际经验
- Java类的初始化顺序
- nginx.conf详细说明和负载均衡配置
- java核心之内容分配管理
- 如何更改InstallShield打包的应用程序GUID
- 基于Android设备的 Kali Linux渗透测试教程(内部资料)