subprocess.Popen
takes a cwd
argument to set the Current Working Directory; you'll also want to escape your backslashes ('d:\test\local'
), or use r'd:estlocal'
so that the backslashes aren't interpreted as escape sequences by Python. The way you have it written, the
part will be translated to a tab.
So, your new line should look like:
subprocess.Popen(r'c:mytoolool.exe', cwd=r'd:estlocal')
To use your Python script path as cwd, import os
and define cwd using this:
os.path.dirname(os.path.realpath(__file__))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…