Python代码备忘

学习,练习,记录

导航

2012年3月19日 #

简化字符串的 translate 方法的使用

摘要: import stringdef Translator(frm = '', to = '', delete = '', keep = None): if len(to) == 1: to = to * len(frm) trans = string.maketrans(frm, to) if keep is not None: allchars = string.maketrans('', '') delete = allchars.translate(allchars, keep.translate(allcha 阅读全文

posted @ 2012-03-19 13:14 sysuoyj 阅读(323) 评论(0) 推荐(0) 编辑