(May-04-2021, 03:30 PM)herwin Wrote: The problem appears to be the blank space in the middle of the string (between 'program' and 'files' in the file path)Should not be a problem,a quick test.
So this run fine no error,and open programs.
import subprocess core = r'C:\Program Files\Core Temp\Core Temp.exe' prg = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' print(repr(core)) print(repr(prg)) subprocess.Popen([core]) subprocess.Popen([prg])
Output:E:\div_code\new
λ python p_open.py
'C:\\Program Files\\Core Temp\\Core Temp.exe'
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
If put paths is a file,run fine.Output:# prog.csv
C:\Program Files\Core Temp\Core Temp.exe,C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
import subprocess import csv with open('prog.csv') as f: reader = csv.reader(f, delimiter=',') prog_lst = list(reader) for prog in prog_lst[0]: subprocess.Popen([prog])so
prog_lst
looks like this,se that there are two \\
when read from a file,then there is no need for
r
(raw string) as if write/copy path yourself. >>> prog_lst [['C:\\Program Files\\Core Temp\\Core Temp.exe', 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe']]