小编emm*_*ila的帖子

错误:不能在类似字节的对象上使用字符串模式

我正在使用 Python RegEx 显示所有连接到计算机的互联网无线配置文件(TypeError: cannot use a string pattern on a bytes-like object)。我的第二行有错误,请任何人帮助识别我的错误。谢谢

我的程序

import subprocess,re
command = "netsh wlan show profile"
output = subprocess.check_output(command, shell=True)  
network_names = re.search("(Profile\s*:\s)(.*)", output)  
print(network_names.group(0))
Run Code Online (Sandbox Code Playgroud)

………………………………………………………………………………………………………………………………………………………… ...

错误

line 8, in <module>


 return _compile(pattern, flags).search(string)


TypeError: cannot use a string pattern on a bytes-like object
Run Code Online (Sandbox Code Playgroud)

python python-requests python-3.8

4
推荐指数
1
解决办法
4833
查看次数

标签 统计

python ×1

python-3.8 ×1

python-requests ×1