Essentially what I am trying to do is
from subprocess import call
print call(['echo', '%path%'])
however 'echo' is not recognized as an executable is there some kind of workaround?
I don't have a windows computer, but you could probably use os.environ
to get it without relying on an external utility -- On *NIX it looks something like:
import os
print (os.environ['PATH'])
mgilson有更好的建议,但无论如何,仅供参考, echo
是cmd.exe
的内置命令:
subprocess.call("CMD /C ECHO %PATH%")
echo
is not an executable, it is a shell command.
To execute shell commands, use:
subprocess.call("echo %PATH%", shell=True)
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.