![]() For example, sys.executable might be a path like /usr/local/bin/python. sys.executable is the absolute path to the Python executable that your program was originally invoked with.If you run this, you will receive output like the following: First, though, you need to import the subprocess and sys modules into your program: import subprocess You can use the n function to run an external program from your Python code. You can review these tutorials for the necessary background information: To get the most out of this tutorial, it is recommended to have some familiarity with programming in Python 3. We’ll review its different uses and main keyword arguments. Subprocess includes several classes and functions, but in this tutorial we’ll cover one of subprocess’s most useful functions: n. Since any program you can access on your computer can be controlled by subprocess, the examples shown here will be applicable to any external program you might want to invoke from your Python code. For example, you might want to invoke git from within your Python code to retrieve files in your project that are tracked in git version control. You might find subprocess useful if you want to use another program on your computer from within your Python code. Python 3 includes the subprocess module for running external programs and reading their outputs in your Python code. The author selected the COVID-19 Relief Fund to receive a donation as part of the Write for DOnations program. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |