Python 判断字符串是否全为中文
def is_all_chinese(strs):for _char in strs:
if not '\u4e00' <= _char <= '\u9fa5':
return False
return True 自占沙发{:10_248:} 抢占前排 那我抢个小板凳 抢错了,板凳已经不是我的了{:10_266:} 本帖最后由 wcshds 于 2020-4-1 12:54 编辑
import re
def is_all_chinese(strs):
try:
result = re.match(r"[\U00004E00-\U00009FFC\U00003400-\U00004DBF\U00020000-\U0002A6DD\U0002A700-\U0002B734\U0002B740-\U0002B81D\U0002B820-\U0002CEA1\U0002CEB0-\U0002EBE0\U00030000-\U0003134A]{1,}", strs).group()
except:
return False
if result == strs:
return True
return False
页:
[1]