string = \'i am a chinese boy,but she is a japanese girl,she is russia girl.please tell me that how do i choice?\' \\
\'and can we happyniess?can we happyniess?\'
# 1.直接替换不需要的符号,在使用精灵函数切割
print(string.replace(\',\', \' \').replace(\'?\', \' \').replace(\'.\', \' \').split())
# 2.依次查找函数中不需要的符号,与列表对比后替换,在使用精灵函数切割
def st(text, list): for i in list: text = text.replace(i, \'\') print(text.split()) st(string, [\',\', \'?\', \'.\'])
结果:
[\'i\', \'am\', \'a\', \'chinese\', \'boybut\', \'she\', \'is\', \'a\', \'japanese\', \'girlshe\', \'is\', \'russia\', \'girlplease\', \'tell\', \'me\', \'that\', \'how\', \'do\', \'i\', \'choiceand\', \'can\', \'we\', \'happyniesscan\', \'we\', \'happyniess\']
继续阅读与本文标签相同的文章
上一篇 :
C/C+不为人知的黑客技术
-
干货送上,小程序运动步数实战分享
2026-05-19栏目: 教程
-
ZAO 背后的深度学习算法原理浅析
2026-05-19栏目: 教程
-
应用优雅上下线
2026-05-19栏目: 教程
-
FFMPEG常用命令收录(持续更新)
2026-05-19栏目: 教程
-
OpenSSL 1.1.1的裁剪
2026-05-19栏目: 教程
