如何运行an "。使用python从“C:\程序文件(x86)”执行“文件”?

时间:2022-06-27 06:59:51

Context: Basically I want to create a python program that asks me what Software I want to run, as soon as I start my computer.

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

Usefull code: os.chdir(r'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'). And that's the error I got :

有用代码:操作系统。(r 'C:/程序文件目录(x86)/谷歌/铬/应用程序/ chrome.exe”)。这就是我的错误:

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

FileNotFoundError Traceback(最近一次调用last) in()——>1os。(r“C:/程序文件目录(x86)/谷歌/铬/应用程序/ chrome.exe”)

FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'"

[WinError 2] Das系统kann die angegebene Datei错误提示:"C:/Program Files (x86)/谷歌/Chrome/Application/chrome.exe "

The translation for "Das System kann die angegebene Datei nicht finden:" is the system was unable to find the file.

翻译为“Das系统kann die angegebene Datei nicht finden:”is The System was unable to find The file。

Problem: My problem is that I can't run any ".exe", or any type of files, because of the white spaces in "C:\Program Files (x86) ", so my question would be how can I bypass that? / What could I use to make it work?

问题:我的问题是我不能跑”。exe或任何类型的文件,因为“C:\程序文件(x86)”中的空格。,所以我的问题是,我怎样才能绕过这个问题呢?/我能用什么使它工作?

PS: I searched, on various forums, but this problem doesn't seem to be very common... Or I didn't search enough.

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

1 个解决方案

#1


0  

Use os.system() or give a folder path to change dir in os.chdir() not an executable file (why would you want to change into an executable? You can't do that)

使用os.system()或提供一个文件夹路径来更改os.chdir()中的dir,而不是可执行文件(为什么要更改为可执行文件?你不能这么做)

#1


0  

Use os.system() or give a folder path to change dir in os.chdir() not an executable file (why would you want to change into an executable? You can't do that)

使用os.system()或提供一个文件夹路径来更改os.chdir()中的dir,而不是可执行文件(为什么要更改为可执行文件?你不能这么做)