So I have a bunch of aliases and Command Line prompt programs, and my main program works by inputting b into the cmd.exe, followed by some filepath names and what not. How would I run those arguments in my python script? So that it mimics the action i am doing in the cmd?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You should use the subprocess module. In particular, subprocess.call will run command line programs for you.
You can do this using subprocess
For example, this call bellow gets the output of the program and stores it as a string, using
.call
will help with calling it and for more accurate control use.Popen
Check out Sarge - a wrapper for subprocess which aims to make life easier for anyone who needs to interact with external applications from their Python code. and Plumbum - a small yet feature-rich library for shell script-like programs in Python.
or you can use
for example:
will launch the notepad with the command line behind.
hope this helps