import re
# 测试文本
test = '<h1>hello 你好, world 世界</h1>'
# 中文匹配正则
chinese_pattern = '[u4e00-u9fa5]+'
says = re.findall(chinese_pattern, test)
# 输出提取的内容
hi = ''
for say in says:
# print(say)
hi += say + ','
hi = hi.strip(',')
# 打印结果:你好,世界
print(hi)
最后
以上就是昏睡小白菜最近收集整理的关于Python3 提取中文的正则表达式的全部内容,更多相关Python3内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复