Sometimes it is necessary to remove all (or some subset of) xml style tags (eg.) from a string. If you’re familiar with PHP, then you probably already know about the strip_tags() function. Here is a simple equivalent to strip_tags() written in Python. 1## Remove xml style tags from an input string. 2# 3# @param string The input string. 4# @param allowed_tags A string to specify tags which should not be removed. 5def strip_tags(string, allowed_tags=''): 6 if allowed_tags != '': 7 # Get a list of all allowed tag names. 8 allowed_tags_list = re.sub(r'[\/<> ]+', '', allowed_tags).split(',') 9 allowed_pattern = '' 10 for s in allowed_tags_list: 11 if s == '': 12 continue; 13 # Add all possible patterns for this tag to the regex. 14 if allowed_pattern != '': 15 allowed_pattern += '|' 16 allowed_pattern……
一、故障现象 现网的一台小库主机(使用的redhat 6.x)在一次例行维护进行重启后,发现无法正常启动。通过HP ILO口登陆查看主机停留下“ An error occurred during the file system check” 处报错。具体截图类似如下(问题时未截图,该图为网上找来的图): fstab 二、故障处理 在修复时,查看主机的/etc/fstab……
对于大量的数据采集除了多线程,就只有异步来实现了。本文是通过twisted框架来实现异步采集,原文来自:http://oubiwann.blogspot.com/2008/06/async-batching-with-twisted-walkthrough.html 。 Async Batching with Twisted: A Walkthrough……