python的cmd命令行在哪里


本文摘自php中文网,作者anonymity,侵删。

python进行cmd命令行的执行,最典型的模块是使用subprocess。

一,执行cmd并读取返回值

1

2

3

4

5

6

7

import subprocess

p = subprocess.Popen("ls",

        stdout=subprocess.PIPE, universal_newlines=True)

p.wait()

result_lines = p.stdout.readlines()

for line in result_lines:

    print(line)

二,执行cmd命令

1

2

3

4

import subprocess

cmd = "ffmpeg -i bb_short.mp4 -vf \"select=\'eq(pict_type,  PICT_TYPE_I)\'\" -vsync vfr out%d.png"

p = subprocess.Popen(cmd, shell=True)

p.wait()

以上就是python的cmd命令行在哪里的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python简称是什么

Python市场需求量大吗

Python读写excel文档

安装Python时没有scripts文件夹如何处理

Python标准库有哪些

Python多进程的用法示例(代码)

Python操作postgresql

Python比php好在哪?

Python中collection模块的简单介绍(附示例)

安利大家一个Python大数据分析神器

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...