代码:
from os import popen
from re import search, findall
from time import sleep
def show_saved():
s = popen('netsh wlan show profiles').read()
ssids = findall(r'所有用户配置文件 : (.*)\n', s)
return ssids
def show_pwd(ssid):
s = popen(f'netsh wlan show profiles "{ssid}" key=clear').read()
try: pwd = search(r'关键内容( *): (.*)', s).groups()[1]
except: pwd = 'NOT FOUND!'
print(ssid+"的密码是:"+pwd)
if __name__ == '__main__':
print('Input ssid to show its password, or input "/exit" to exit.\n')
print('All saved wifi ssids: ')
ssids = show_saved()
print("》》所有wifi密码列表:《《")
for ssid in ssids:
print(' ' + ssid)
show_pwd(ssid)
效果图: