如上cmd里直接输入C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
的话,会被空格隔开,导致识别为空格之前的部分。
"C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe"
cmd里输入如上命令,会打开空白的potplayer。
"C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "C:\1.wav" "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" C:\1.wav
cmd里输入如上命令,会打开potplayer,然后播放wav文件。
上面两条,命令部分必须带引号,因为exe的绝对路径中带有空格。
如果C:\Users\你的用户名\
下面也有一个1.wav文件,那么也可以使用:
"C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "1.wav" "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" 1.wav
import subprocess subprocess.run(["C:\\Program Files\\DAUM\\PotPlayer\\PotPlayerMini64.exe", "2.wav"])#当前目录下有wav文件 subprocess.run(["C:\\Program Files\\DAUM\\PotPlayer\\PotPlayerMini64.exe", "C:\\1.wav"])#绝对目录下有wav文件
@echo off start "" "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "1.wav" %当前目录% start "" "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "C:\1.wav" %绝对目录%
前提:python脚本和bat脚本在同一目录下。
bat如下("%1"
代表第一个参数,也就是python代码里的2.wav
):
@echo off start "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" "%1"
python如下:
import subprocess subprocess.run(["1.bat", "2.wav"])#当前目录下有wav文件 subprocess.run(["1.bat", "C:\\1.wav"])#绝对目录下有wav文件