test5.py 317 B

123456789101112131415
  1. """
  2. 不良内容过滤
  3. """
  4. import re
  5. def main():
  6. sentence = '你丫是傻叉吗? 我操你大爷的. Fuck you.'
  7. purified = re.sub('[操肏艹]|fuck|shit|傻[比屄逼叉缺吊屌]|煞笔',
  8. '*', sentence, flags=re.IGNORECASE)
  9. print(purified)
  10. if __name__ == '__main__':
  11. main()