问题遇到的现象和发生背景
python,re.search("^ifcfg-.*?[0-9]$",wangka)获取网卡失败
问题相关代码,请勿粘贴截图
# -*- coding:utf-8 -*-
import os
import os.path
import re
import time
import sys
dir1 = "/etc/sysconfig/network-scripts/"
def list_net():
for wangka in os.listdir(dir1):
# ifcfg1=re.search("^ifcfg-.*?[0-9]$",wangka)
print(re.search("^ifcfg-.*[0-9]$", wangka))
#print wangka
#print ifcfg1
list_net()
运行结果及报错内容
None
None
None
None
None