Colab

import os

os.system("del an_important_file.txt")

0
os.system("dir")

0
os.system("notepad an_important_file.txt")
print("finished")

finished
import subprocess

p = subprocess.Popen("notepad an_important_file.txt")
print("subprocess opened", p.pid)
print(p.wait())

subprocess opened 1776
0
p = subprocess.Popen("git add", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print("subprocess opened", p.pid)
print(p.wait())

subprocess opened 11412
128
p.stderr.readlines()

[b'fatal: not a git repository (or any of the parent directories): .git\n']
for line in p.stderr:
    print(line)

b'fatal: not a git repository (or any of the parent directories): .git\n'