您的位置:首页 > 编程语言 > Python开发

python 实现过虑配置文件去掉 #号行

2013-09-26 08:34 387 查看
以下是实现代码,不过,大家可以使用shell去实现很简单
[root@localhost conf]# cat r.py
import sys
import re
file=open('httpd.conf')
try:
all_file=file.read()
pattern = re.compile('(^[^#|\n]+)', re.M)
result = pattern.findall(all_file)
for x in result:
print x
finally:
file.close()

本文出自 “游造技术博客” 博客,请务必保留此出处http://youzao.blog.51cto.com/3946111/1301890
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: