This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def replace_matched_part(pattern, lstring, repl_str, group_name): | |
""" | |
:param pattern: 类似 '.*?_(?P<char>\w)_\d\.\w+$' | |
:param lstring: 需要替换的字符串 | |
:param repl_str: 匹配部分替换成的字符串 | |
:param group_name: 匹配中的组名 char | |
:return: | |
""" | |
def _rep_func(m): | |
return ''.join([m.string[:m.start(group_name)], repl_str, m.string[m.end(group_name):]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_emoji(data): | |
""" | |
去除表情 | |
:param data: | |
:return: | |
""" | |
if not data: | |
return data | |
if not isinstance(data, basestring): | |
return data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from HTMLParser import HTMLParser | |
def remove_html_tags(html): | |
""" | |
移除html 标签类 方法 | |
""" | |
if not html: | |
return html | |
if not isinstance(html, basestring): | |
return html |