Hy am using Python RegEx to show all internet wirless profiles connected to a computer.There is error (TypeError: cannot use a string pattern on a bytes-like object)
in my Second last line pls anyone help to identifi my mistake.Thanks
My Program
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))
.....................................................
ERROR
line 8, in <module>
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
output = output.decode()
?subprocess
returnbytes
and you have to manually convert tostring
/unicode
(using default'utf-8'
or other encoding - ie.decode('latin1')
- if system uses different encoding thenutf-8
) – Wax