我用python脚本从文件中读取每个ip并使用密码在该ip上安装代理,有5-6个密码,如果一个密码不起作用,它应该逐个尝试其他所有密码。 我的一个密码脚本的一些代码是:
p = subprocess.Popen(["./linux_autodisc"], stdout=subprocess.PIPE)
p1 = str(p.communicate())
if '1 devices were successfully added/updated' in p1:
print ('Sucessfull Completed Ip: ' +line)
f6 = open("/root/nix_bsd_mac_inventory-master/SucessfullIp.txt","a")
f6.write("\n"+line)
f6.close()
else:
print "Unsuccessfull"
如何为5-6个密码包含多个else-to-run脚本,最后一个else应该返回trued all password而不是successful。你知道吗
为了保持代码更清晰,我建议您提取如下函数:
else语句的堆积将使您的代码更难阅读/理解,并且会使将来的更改复杂化。你知道吗
这是我对你剧本的建议:
相关问题 更多 >
编程相关推荐