Python can be used in executing cmd command os and subprocess two modules.
The difference is that is blocking the os, subprocess is non-blocking, so we generally use the subprocess is more appropriate.
Next, I first give a command to query the connected device and see how kind of written in python. Command used to adb devices.
method one:
import os
os.system ( 'adb devices') # connection apparatus acquires
operation result
List of devices attached
Q8DCGQA6JBQRSAI device
Second way:
import subprocess
order = 'adb devices' # Get connected device
pi= subprocess.Popen(order,shell=True,stdout=subprocess.PIPE)
print (pi.stdout.read ()) # print results
operation result
b'List of devices attached\r\AQ8DCGQA6JBQRSAI\tdevice\r\n\r\n'