devices = subprocess.getoutput('ios-deploy -c') print(devices)
如上代码中,subprocess.getoutput函数首先在终端执行命令
ios-deploy -c
然后获取linux 中shell终端命令执行的结果,以字符串格式保存到devices;subprocess还有其他函数,是和shell终端交互的,以后用到再加,输出结果如下
['[....] Waiting up to 5 seconds for iOS device to be connected', "[....] Found 26b58f4034c7cabd1b34a7fbb8eXXXXXXX (N71mAP, iPhone 6s, iphoneos, arm64) a.k.a. 'iPhone6s' connected through USB."]