Код:
import subprocess
mac = subprocess.Popen(['ifconfig', 'wls1'], stdout=subprocess.PIPE)
omac = mac.stdout.read()
a = (omac.find('H'))
print(a)
__
Результат:
Traceback (most recent call last):
File "mac.py", line 4, in <module>
a = (omac.find('H'))
TypeError: 'str' does not support the buffer interface
Код после фикса:
import subprocess
mac = subprocess.Popen(['ifconfig', 'wls1'], stdout=subprocess.PIPE)
omac = mac.stdout.read()
tmac = omac.encode('utf-8')
a = (tmac.find('H'))
print(a)
__
Результат:
raceback (most recent call last):
File "mac.py", line 4, in <module>
tmac = omac.encode('utf-8')
AttributeError: 'bytes' object has no attribute 'encode'