您正在使用
f.read()
多次并打印其内容。使用
with open
安全打开和关闭。
import subprocess
a = subprocess.check_output(['netsh' , 'wlan' , 'show' , 'profiles'])
a = a.decode('utf-8')
a = a.replace(' All User Profile :' , '')
a = a.replace('User profiles' , '')
a = a.replace('<None>' , '')
a = a.replace( 'Profiles on interface Wi-Fi:', '')
a = a.replace(':' , '')
a = a.replace('Group policy profiles (read only)' , '')
a = a.replace('
a = a.replace('-------------' , '')
print(a)
a = a.replace(' ' , '')
with open('ssids.txt' , 'w') as f:
f.write(a)
with open('ssids.txt' , 'r') as f:
for line in f:
l = subprocess.run('netsh wlan show profiles "' + line + '"' , capture_output = True , text = True)
print(l)
print('follwed')