Convert a linux command to python command

Would you please say me how can I convert this code:

path to app/adb devices | awk 'NR>1{print $1}' | xargs -n1 -I% adb -s % install app.apk

to python command?

Answer

You can always utilize the os.system() method:

import os

command = "path to app/adb devices | awk 'NR>1{print $1}' | xargs -n1 -I% adb -s % install app.apk"

os.system(command)