正则表达式在windows的python程序中不起作用

2024-05-19 00:42:16 发布

您现在位置:Python中文网/ 问答频道 /正文

import subprocess, re
command = "netsh wlan show profile"
networks = subprocess.check_output(command, shell=True)
network_names_list = re.findall("(Profile\s*:\s)(.*)", "networks")
print(network_names_list)

此代码将输出空列表,而不是wlan配置文件


Tags: importreoutputnamescheckshownetworkshell
1条回答
网友
1楼 · 发布于 2024-05-19 00:42:16

你是说

networks = subprocess.check_output(command, shell=True)
network_names_list = re.findall("(Profile\s*:\s)(.*)", networks)
#                                                      ^^^^

您使用了字符串"networks"而不是变量networks(它可能保存您的输出)

相关问题 更多 >

    热门问题