import os, re
full_results = [re.findall('^[\w\?\.]+|(?<=\s)\([\d\.]+\)|(?<=at\s)[\w\:]+', i) for i in os.popen('arp -a')]
final_results = [dict(zip(['IP', 'LAN_IP', 'MAC_ADDRESS'], i)) for i in full_results]
final_results = [{**i, **{'LAN_IP':i['LAN_IP'][1:-1]}} for i in final_results]
您可以使用命令
arp -a
并获取os.popen
的结果:样本输出:
^{pr2}$arp -a
给出执行该命令的计算机网络上所有设备的完整列表。在相关问题 更多 >
编程相关推荐