python - 子进程 AttributeError:“列表”对象没有属性“读取”
问题描述
我找到了一个将您的 wifi 密码输出到控制台的程序,但出现以下错误:
AttributeError: 'list' object has no attribute 'read'
我应该怎么办?(我使用python 3.8。)
import subprocess
data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="backslashreplace").split('\n')
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
for i in profiles:
try:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8', errors="backslashreplace").split('\n')
results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
try:
print ("{:<30}| {:<}".format(i, results[0]))
except IndexError:
print ("{:<30}| {:<}".format(i, ""))
except subprocess.CalledProcessError:
print ("{:<30}| {:<}".format(i, "ENCODING ERROR"))
input("")
解决方案
推荐阅读
- wpf - 如何在 powershell 中为变量创建自己的驱动程序
- python - 无法在 python 上绘制 KDE
- html - 如何使用 flexbox 设置 div 的宽度
- c# - 通过匹配文本的字符串部分删除重复项
- testing - 无法重复使用 Https 测试脚本记录器来完成操作,因为响应代码 - 401 显示
- powershell - 如何在powershell的XML数组中查找变量值?
- iis - 状态 200,sc-win32-status 为 64 大请求
- javascript - onClick 需要 2 次点击
- javascript - 将 RX 与 yeoman 生成器一起使用
- java - 从 jar 与 IntelliJ 运行时,Spring 以不同的顺序自动装配 bean - 无法启动 bean 'subProtocolWebSocketHandler' 没有处理程序