#-*- coding:utf-8 -*-
def is_chinese(s):
rt = False
if s>= u"\u4e00" and s<= u"\u9fa6":
rt = True
return rt
ss = "中文测试測試請說ha".decode("utf-8")
for row in ss:
print row,is_chinese(row)
def is_chinese(s):
rt = False
if s>= u"\u4e00" and s<= u"\u9fa6":
rt = True
return rt
ss = "中文测试測試請說ha".decode("utf-8")
for row in ss:
print row,is_chinese(row)
本文提供了一个简单的Python函数,用于检测字符串中是否包含中文字符。通过遍历字符串并利用Unicode编码范围判断每个字符是否为中文。

被折叠的 条评论
为什么被折叠?



