如何使用python从“C:\Program Files(x86)”运行“.exe”文件?

2024-04-26 04:32:29 发布

您现在位置:Python中文网/ 问答频道 /正文

上下文:基本上,我想创建一个python程序,在启动计算机后,它会询问我要运行什么软件。你知道吗

有用代码:os.chdir(r'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe')。这就是我的错误:

FileNotFoundError Traceback (most recent call last) in () ----> 1 os.chdir(r"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'")

FileNotFoundError:[WinError 2]Das System kann die angegebene Datei nicht finden:“C:/程序文件(x86)/Google/Chrome/Application/chrome.exe“'”

“Das System kann die angegebene Datei nicht finden:”的翻译是系统找不到文件。你知道吗

问题:我的问题是我不能运行任何“.exe”或任何类型的文件,因为“C:\Program files(x86)”中有空格,所以我的问题是如何绕过它?/我能用什么使它工作?你知道吗

PS:我在各种论坛上搜索过,但这个问题似乎并不常见。。。或者我搜索得不够。你知道吗


Tags: 文件程序applicationosgooglefileschromeprogram