K12教育赛事综合服务平台
专注青少年竞赛题库网站
聚乐之家官方网站
下载聚乐之家官方App
需要将文本中的敏感词替换为保留首字符并用 号覆盖剩余字符。例如:"密码"(2字)替换为"密","身份证"(3字)替换为"身**"。请填写横线处的代码。
words = ["密码", "账号", "身份证"] text = "请勿泄露您的密码和身份证号码" for word in words: if word in text: text = text.replace(word, ________) print(text) # 期望输出"请勿泄露您的密*和身**号码"
word[0] + '' (len(word) - 1)
word[0] + '**'
'' len(word)
word[0] + '' len(word)