1,760
edits
Changes
→PART 2 - Running System Commands with subprocess
:#Create a new python file for testing.
:#Import the '''''os''''' module in your python file.
:#You can issue operating system commands by using the '''system()''' function. Try it:<source lang="python">
os.system('ls')
os.system('whoami')
os.system('ifconfig')
</source>Notice that the output from the system programs '''ls''', '''whoami''', and '''ifconfig''' is printed on your screen. Try to compare them with the output from the following function calls:<source lang="python">
ls_return = os.system('ls')
print('The contents of ls_return:',ls_return)