I'm getting error messages by running this python script to get Mac address.This is working very fine with python 2.7 but for python 3.6its throwing error.
import subprocess, re
listOutputMAC = 0
def mac_list():
output = subprocess.check_output("getmac")
print(output)
regex = r"([0-9A-F]{2}[:-]){5}([0-9A-F]{2})"
matches = re.finditer(regex, output)
listOutputMAC = []
for matchNum, match in enumerate(matches):
matchNum = matchNum + 1
listOutputMAC.append("{match}".format(matchNum=matchNum, start=match.start(),
end=match.end(), match=match.group()))
print(output)
return listOutputMAC
var1 = mac_list()
print(var1)
This is my Error log : Traceback (most recent call last):
File "s.py", line 19, in <module>
var1 = mac_list()
File "s.py", line 9, in mac_list
matches = re.finditer(regex, output)
File "C:\Users\Cookie1\Anaconda3\envs\py3\lib\re.py", line 229, in finditer
return _compile(pattern, flags).finditer(string)
TypeError: cannot use a string pattern on a bytes-like object