【发布时间】:2022-08-23 01:27:12
【问题描述】:
我想了解如何执行以下操作:
-
用户将定位多少个 IP 地址? (接收输入 ex. 3 )
-
将每个 IP 放入相同的脚本命令中
- 例如。 (adb -s [IP1] shell [命令]), (adb -s [IP2] shell [命令]), (adb -s [IP3] shell [命令])
-
打印(IP1、IP2、IP3)
import subprocess
import os
##Get IP of devices connected
ip_address = input(\"Enter the IP address you wish to test in the form xxx.xxx.xxx.xxx: \")
ip_address2 = input(\"Enter Next IP address you wish to test in the form xxx.xxx.xxx.xxx: or ENTER \")
ip_address3 = input(\"Enter Next IP address you wish to test in the form xxx.xxx.xxx.xxx: or ENTER \")
ip_address4 = input(\"Enter Next IP address you wish to test in the form xxx.xxx.xxx.xxx: or ENTER \")
ip_address5 = input(\"Enter Next IP address you wish to test in the form xxx.xxx.xxx.xxx: or ENTER \")
##GET THE EVENT TYPE OF EACH RCU
os.system(\"adb -s \" +(ip_address)+ \" shell getevent -c 1\")
event = input(\"Enter the happy meal Value\")
os.system(\"adb -s \" +(ip_address2)+ \" shell getevent -c 1\")
event2 = input(\"Enter the happy meal Value \")
os.system(\"adb -s \" +(ip_address3)+ \" shell getevent -c 1\")
event3 = input(\"Enter the happy meal Value \")
os.system(\"adb -s \" +(ip_address4)+ \" shell getevent -c 1\")
event4 = input(\"Enter the happy meal Value \")
os.system(\"adb -s \" +(ip_address5)+ \" shell getevent -c 1\")
event5 = input(\"Enter the happy meal Value \")
happy = 0
happy2= 0
happy3 = 0
happy4 = 0
happy5 = 0
happy6 = 0
happy7 = 0
happy8 = 0
happy9 = 0
happy10 = 0
happy11 = 0
happy= subprocess.getoutput(\"adb -s \"+(ip_address)+\" shell cat /sys/class/display/mode\")
print(\"{}/// Display Mode/// {}\".format(ip_address, firstDisplay))
happy2= subprocess.getoutput(\"adb -s \"+(ip_address2)+\" shell cat /sys/class/display/mode\")
print(\"{}/// Display Mode/// {}\".format(ip_address2, firstDisplay2))
happy3= subprocess.getoutput(\"adb -s \"+(ip_address3)+\" shell cat /sys/class/display/mode\")
print(\"{}/// Display Mode/// {}\".format(ip_address3, firstDisplay3))
happy4= subprocess.getoutput(\"adb -s \"+(ip_address4)+\" shell cat /sys/class/display/mode\")
print(\"{}/// Display Mode/// {}\".format(ip_address4, firstDisplay4))
happy5 = subprocess.getoutput(\"adb -s \"+(ip_address5)+\" shell cat /sys/class/display/mode\")
print(\"{}/// Display Mode/// {}\\n\".format(ip_address5, firstDisplay5))
while count<100: #[ $n -le 5 ]
count += 1
- 目前我总是要求 5 个输入并为每个 IP 重新编写相同的命令。我觉得有一个更好的方法可以让命令列出一次并不断切换变量。
谢谢
标签: python variables automation script