标签:match print color log www string group replace http
1.
import re replace_values = [‘one‘, ‘two‘, ‘three‘] replace_keys = [str(i) for i in xrange(1, 4)] replace_dict = dict(zip(replace_keys, replace_values)) def replace(match): return replace_dict[match.group(0)] string = ‘1 adfa fa 2 fafsa 3 adfaf‘ print re.sub(r‘(^|\b)[1-3]($|\b)‘, replace, string) 作者:孙竟 链接:https://www.zhihu.com/question/36596275/answer/68175650 来源:知乎 著作权归作者所有,转载请联系作者获得授权。
https://www.zhihu.com/question/36596275
标签:match print color log www string group replace http
原文地址:http://www.cnblogs.com/javastart/p/6322888.html