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
[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
相关文章推荐
- 读取配置文件和自定义配置文件(python实现)
- Python实现配置文件备份的方法
- python在读取配置文件存入列表中,去掉回车符号
- Python实现配置文件备份的方法
- python用ConfigObj读写配置文件的实现代码
- python实现的解析crontab配置文件代码
- python实现数通设备tftp备份配置文件示例
- Python配置文件实现
- 读取配置文件和自定义配置文件(python实现)
- 读取配置文件和自定义配置文件(python实现)
- [python 2.7.5] 实现配置文件的读写
- 在python中实现自定义配置文件解析及应用技巧[yaml and ConfigParser] 推荐
- rcp(插件开发) 去掉plugin_customization.ini文件,在代码中实现配置功能
- Python实现读写INI配置文件的方法示例
- python学习之路之案例1(修改haproxy的配置文件,并实现下线、上线的功能)
- python实现的解析crontab配置文件代码
- python实现数通设备tftp备份配置文件示例
- 去掉plugin_customization.ini文件,在代码中实现配置功能
- Python实现在线上环境优雅的修改配置文件
- [python 2.7.5] 实现配置文件的读写