python console commands code example
Example 1: execute command in python script
import os
os.system("ma Commande")
os.system("cd Documents")
Example 2: python bash command
import os
os.system('clear')
Example 3: python run a system command
import os
cmd = "git --version"
returned_value = os.system(cmd)
Example 4: run python with options
import argparse
import sys
parser = argparse.ArgumentParser(description="Does some awesome things.")
parser.add_argument('message', type=str, help="pass a message into the script")
if __name__ == '__main__':
args = parser.parse_args(sys.argv[1:])
print args.message
Example 5: python execute shell command
python3 yourcode.py
or
python yourcode.py