我希望在python中运行wmplayer,但无法获得正确的语法。下面的代码允许我使用wmplayer.exe播放文件。例如。
启动/d "ProgramFiles(x86)\Windows Media Player“wmplayer.exe e:\Python\escapeVR\videos\screen_sav1.webm
我被困住了,试图把它作为一个操作系统调用。
os.system("start /d "%ProgramFiles(x86)%\Windows Media Player“wmplayer.exe e:\Python\escapeVR\videos\screen_sav1.webm)
导致行连续字符后出现SyntaxError:意外字符
有什么建议吗?
发布于 2019-09-01 14:45:44
你需要转义所有的反斜杠和双引号:
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')https://stackoverflow.com/questions/57743198
复制相似问题