Exécuter la commande dans Python Script
import os
os.system("ma Commande")
#Exemple:
os.system("cd Documents")
Cheerful Caracal
import os
os.system("ma Commande")
#Exemple:
os.system("cd Documents")
import subprocess
print "start"
subprocess.call("sleep.sh")
print "end"
import subprocess
subprocess.call(["sudo", "apt", "update"])
#!/bin/bash
PYCMD=$(cat <<EOF
from datetime import datetime
first_day_of_new_year = datetime(2022, 1, 1)
days_remaining = (first_day_of_new_year - datetime.now()).days
print('{} days remaining in this year'.format(days_remaining))
EOF
)
python3 -c "$PYCMD"
#!/bin/bash
python3
print("Hello World")
exit()
echo "The execution is completed"