That’s the exit code of the Linux command.Ī successful command in Linux returns a 0 exit code and a non-zero exit code is returned in case of failure. We still see the output of the date command but we also see a 0 in the last line. Let’s see what happens when we run the same code in the Python shell: > import os This is the output of the os.system() function: $ python shell_command.py It uses the system function of the os module to run the Linux date command: import os I have created a simple Python script called shell_command.py. Conclusion Using OS System to Run a Command in Python.Print Shell Environment Variables in Python.How to Run Multiple Commands with Subprocess.
0 Comments
Leave a Reply. |