在Python中运行wmplayer.exe
我希望在python中运行wmplayer,但无法获得正确的语法。下面允许我使用wmplayer.exe播放文件。例如 开始/d“ProgramFiles(x86)\Windows Media Player”wmplayer.exe e:\Python\escapeVR\videos\screen\u sav1.webm 我一直试图把它作为操作系统调用 系统(“开始/d”%ProgramFiles(x86)%\Windows Media Player“wmplayer.exe e:\Python\escapeVR\videos\screen\u sav1.webm) 导致语法错误:行连续字符后出现意外字符在Python中运行wmplayer.exe,python,Python,我希望在python中运行wmplayer,但无法获得正确的语法。下面允许我使用wmplayer.exe播放文件。例如 开始/d“ProgramFiles(x86)\Windows Media Player”wmplayer.exe e:\Python\escapeVR\videos\screen\u sav1.webm 我一直试图把它作为操作系统调用 系统(“开始/d”%ProgramFiles(x86)%\Windows Media Player“wmplayer.exe e:\Python
建议,请?您需要避开所有反斜杠和双引号:
os.system("start /d \"%ProgramFiles(x86)%\\Windows Media Player\" wmplayer.exe e:\\Python\\escapeVR\\videos\\screen_sav1.webm")
请注意,如果不希望转义双引号,python支持字符串的单引号。如果使用它们,则不需要转义字符串中的双引号:
os.system('start /d "%ProgramFiles(x86)%\\Windows Media Player" wmplayer.exe e:\\Python\\escapeVR\\videos\\screen_sav1.webm')
太棒了。谢谢。两个都对我很好。太好了!不要忘记确认答案,如果你认为这个问题解决了。谢谢!