我首先要说我对 Python 非常非常陌生。
我曾经有一个 Windows/Dos 批处理文件,以便使用正确的参数集启动 Mencoder,而不必每次都键入它们。
当我试图改进我的脚本时,事情变得一团糟,我决定这是一个尝试用 python 编写代码的好机会。
我想出了:
#!/usr/bin/python
import sys, os
#Path to mencoder
mencoder = "C:\Program Files\MPlayer-1.0rc2\mencoder.exe"
infile = "holidays.avi"
outfile = "holidays (part1).avi"
startTime = "00:48:00"
length = "00:00:15"
commande = "%s %s -ovc copy -oac copy -ss %s -endpos %s -o %s"
os.system(commande % (mencoder, infile, startTime, length, outfile))
#Pause
raw_input()
但这不起作用,Windows 抱怨“C:\Program”不是识别命令。
我试着在这里和那里放一些“\”,但这没有帮助。