我开始学习用python编写代码。我正在做一个udemy课程,我必须用python2和pytho3编写一个程序,在kali-linux中读取Mac地址。 我唯一的问题是,我的re.search命令没有将我的旧Mac地址读到底,而是更改了它。我真的认为代码很好。就在这里,希望有人能帮助我
def get_current_mac(interface):
ifconfig_result = subprocess.check_output(["ifconfig", interface])
mac_address_search_result = re.search(r" \w\w:\w\w:\w\w:\w\w:\w\w:\w\w ", ifconfig_result)
if mac_address_search_result:
return mac_address_search_result
else:
print(" Could not read Mac Address ")
下面是出现的错误:
Current mac =<_sre.SRE_Match object at 0x7f7ebbf22ab0>
Changing MAC address for eth0 to 11:22:33:44:44:11
SIOCSIFHWADDR: Cannot assign requested address
Error, try again
谢谢,我真的希望能得到一些帮助
re.search
返回一个Match
对象。如果需要匹配的字符串:相关问题 更多 >
编程相关推荐