当前位置:主页 > 软件编程 > Python代码 >

python 使用正则表达式按照多个空格分割字符的实例

时间:2021-05-31 08:23:26 | 栏目:Python代码 | 点击:

程序代码如下

import os
import re
os.system("nmap -sP 192.168.3.0/24") //扫描IP
mac = os.popen("cat /proc/net/arp ").readlines() //按行读取
length = len(mac)
for i in range(1,length):
    b= re.split(r" +",mac[i])  //按照多个空格分割
    if(b[2]=='0x2'):
        print b[3]

原始数据如下

python 正则表达式按照多个空格分割字符

处理后如下

python 正则表达式按照多个空格分割字符

成功去掉空格!

您可能感兴趣的文章:

相关文章