如下是實現代碼,不過,你們可使用shell去實現很簡單shell
[root@localhost conf]# cat r.py ide
import sysit
import reclass
file=open('httpd.conf')import
try:file
all_file=file.read()im
pattern = re.compile('(^[^#|\n]+)', re.M)di
result = pattern.findall(all_file)view
for x in result:vi
print x
finally:
file.close()