敏感词优化
对于敏感词进行特定格式化
如: xxx || xxx || xxx || xxx
[Python] 纯文本查看 复制代码def read_file(file, char):
with open(file, 'r', encoding='utf-8') as f:
text_list = f.readlines()
# 去除列表中存在的换行符,界定符等
new_list = [line.strip() for line in text_list]
sensitiveness = f' {char} '.join(new_list)
print(sensitiveness)
if __name__ == '__main__':
file_path = input('请输入你的敏感词文件(绝对路径):')
character = input('请输入分割的字符: ')
read_file(file_path, character)