保护用户隐私或打码
def mark_star(name: str, ratio=0.6): l = len(name) star_len = int(l * ratio) remain_len = l - star_len print(remain_len) if remain_len % 2 == 0: remain_forward, remain_backward = int(remain_len / 2), int(remain_len / 2) else: remain_forward, remain_backward = int(remain_len / 2), int(remain_len / 2) + 1 marked_name = name[0: remain_forward] + "*"*star_len + name[-remain_backward:] return marked_name