import hashlib import re def trim_space(input_str): result = re.sub(' {2,}', ' ', input_str) return result def get_str_md5(param_str): if isinstance(param_str, str): param_str = param_str.encode("utf-8") m = hashlib.md5() m.update(param_str) return m.hexdigest() def transform_full_width_number(input_str): d = { '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9' } for _ in d: input_str = input_str.replace(_, d[_]) return input_str