第26187题 单选题
以下Python代码实现敏感词替换为保留首字符其余为*,横线处应填写的内容是?

需要将文本中的敏感词替换为保留首字符并用 号覆盖剩余字符。例如:"密码"(2字)替换为"密","身份证"(3字)替换为"身**"。请填写横线处的代码。

words = ["密码", "账号", "身份证"]
text = "请勿泄露您的密码和身份证号码"
for word in words:
    if word in text:
        text = text.replace(word, ________)
print(text) # 期望输出"请勿泄露您的密*和身**号码"
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析