简体   繁体   中英

Python how to start a program from current working directory

For example in batch (windows) you can use %CD%\\ or .\\ to start something from cwd but I dont know how to do it on python...

I tried subprocess.call(['.\\somedirectory\\someprogram.exe']) And subprocess.call(['\\\\somedirectory\\someprogram.exe'])

edit: Also the command I used in batch is: start %CD%\\somedirectory\\someprogram.exe or start .\\somedirectory\\someprogram.exe

I havent tested it but this should work:

from subprocess import call
call(["start %CD%\somedirectory\someprogram.exe", "-l"])

However your filepath declaration seems a bit strange to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM