python 判断字符串中是否含有汉字或非汉字的实例
作者:多动脑,多动手 时间:2022-07-01 11:25:59
model中compile值可以根据需要更改,满足不同的检测需求
#判断一段文本中是否包含简体中文
import re
zhmodel = re.compile(u'[\u4e00-\u9fa5]') #检查中文
#zhmodel = re.compile(u'[^\u4e00-\u9fa5]') #检查非中文
contents = u'(2014)深南法民二初字第280号'
match = zhmodel.search(contents)
if match:
print(contents)
else:
print(u'没有包含中文')
来源:https://blog.csdn.net/wu1yr/article/details/81630494
标签:python,字符串,汉字,非汉字
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python中Genarator函数用法分析
2023-01-03 16:50:52
如何给windows设置定时任务并运行python脚本
2023-09-18 13:40:19
![](https://img.aspxhome.com/file/2023/8/76928_0s.jpg)
SQL语句参考及记录集对象详解
2008-11-25 11:47:00
Python中使用中文的方法
2021-09-26 05:46:39
Python 十大经典排序算法实现详解
2021-10-01 02:55:24
![](https://img.aspxhome.com/file/2023/4/66924_0s.png)
python 获取文件列表(或是目录例表)
2021-06-27 20:14:24
python模块和函数帮助文档快速查看方法示例
2023-03-31 00:24:04
asp select下拉菜单选择图标并实时显示
2011-04-03 10:33:00
Python djanjo之csrf防跨站攻击实验过程
2021-12-31 04:53:03
![](https://img.aspxhome.com/file/2023/5/110025_0s.png)
Python命令行定时任务自动化工作流程
2023-01-01 20:52:51
![](https://img.aspxhome.com/file/2023/0/99690_0s.png)
pytest fixtures装饰器的使用和如何控制用例的执行顺序
2023-04-11 22:56:09
怎样处理 MySQL中与文件许可有关的问题
2008-11-27 16:12:00
Python利用PsUtil实现实时监控系统状态
2022-11-26 12:43:11
DD_belatedPNG,解决IE6不支持PNG绝佳方案
2009-04-27 16:30:00
python中如何提高图像质量
2023-05-17 17:02:03
![](https://img.aspxhome.com/file/2023/4/86424_0s.jpg)
python打印异常信息的两种实现方式
2023-11-17 15:37:41
Python Django教程之模型中字段验证详解
2021-01-04 18:56:48
![](https://img.aspxhome.com/file/2023/3/102783_0s.png)
关于 Python opencv 使用中的 ValueError: too many values to unpack
2023-07-26 23:46:36
Python多进程机制实例详解
2021-04-10 00:16:44
Python读取HTML中的canvas并且以图片形式存入Word文档
2022-09-03 04:50:33
![](https://img.aspxhome.com/file/2023/0/89430_0s.png)