これを実行しようとすると、「ファイルが見つかりません」というエラーが表示され続けます。絶対パスを見つけて割り当てないのはなぜですか? これが私のコードです:
file = "/" + arr[2] + ".exe"
print(file)
path = os.path.abspath(file)
print(path)
subprocess.Popen(path)
localtime = time.asctime(time.localtime(time.time()))
print(arr[2] + " opened at " + localtime + "\n")
出力される内容は次のとおりです。
/firefox.exe
C:\firefox.exe
Traceback (most recent call last):
File "C:\Python33\lib\subprocess.py", line 1090, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
ユーザー入力に基づいて開いているプログラムをプログラムで見つけようとしています...間違った方法で行っているのかもしれませんが、これは誰かがそれを行うことを提案した方法です。Firefox.exe は C:/Program Files/Firefox/firefox.exe にあります。
どんな助けでも素晴らしいでしょう!ありがとう!