在python中运行cmd [英] Running cmd in python

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

问题描述

Atm我将其作为代码,第一行似乎运行良好,但第二行给出了错误信息.

Atm I have this as my code, the first line seems to work well but the 2nd gives errrors.

os.chdir('C://Users/Alex/Dropbox/code stuff/test')
subprocess.call('ffmpeg -i test%d0.png output.avi')

另外,当我尝试以此方式运行它时,它会发出1s的cmd闪烁,然后什么也没发生

Also when I try to run it as this, it gives a 1s cmd flicker and then nothing happens

os.system('ffmpeg -i test%d0.png output.avi')

推荐答案

对于寻找答案的后代来说,这很有用.(您必须用空格将命令分开.)

For the later generations looking for the answer, this worked. (You have to separate the command by the spaces.)

import os
import subprocess
os.chdir('C://Users/Alex/')
subprocess.call(['ffmpeg', '-i', 'picture%d0.png', 'output.avi'])
subprocess.call(['ffmpeg', '-i', 'output.avi', '-t', '5', 'out.gif'])

这篇关于在python中运行cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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