gpt4 book ai didi

python - 如果我使用新列表,如何获取路由器的 MAC 地址

转载 作者:太空宇宙 更新时间:2023-11-04 03:41:22 27 4
gpt4 key购买 nike

我编写此脚本是为了在 ESSID 为 Home 时获取路由器的 mac 地址

        proc = Popen(['iwlist', 'wlan0', 'scan'], stdout=PIPE)
for line in proc.communicate()[0].split('\n'):
if ' ESSID:' in line:
intext=str(line)
m2=search('ESSID:".*" ',intext)
ESSID=m2.group(0).split('"')[1]
if ESSID =="home":
if ' - Address:' in line: # first line in iwlist scan for a new AP
intext=str(line)
m2=search('Address: .*',intext)
adress_router=m2.group(0).split('')[1]

但是我有这个错误。

Traceback (most recent call last):
File "att_de.py", line 80, in <module>
routeur()
File "att_de.py", line 23, in routeur
ESSID=m2.group(0).split('"')[1]
AttributeError: 'NoneType' object has no attribute 'group'

我需要帮助。谢谢。

最佳答案

我的猜测是您的 'ESSID:".*"' 中的最后一个空格让您感到困惑。如果这没有帮助,请在遇到错误之前添加一个 print intext 语句,并将输出添加到您的问题

关于python - 如果我使用新列表,如何获取路由器的 MAC 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29502592/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com