python一记 判断中文

2021-05-19 15:49:38 浏览数 (1)

判断是中文

代码语言:javascript复制
#-*- coding:utf-8 -*-
import random

def check_contain_chinese(check_str):
	for ch in check_str.decode('utf-8'):
		if u'u4e00' <= ch <= u'u9fff':
			return True
	return False

产生随机中文

代码语言:javascript复制
def iter_chinese():
	str =''
	for i in range(0x5E00,0x5E30):
		str = unichr(i)
	print str

	str=''
	for i in range(100):
		str = unichr(random.randint(0x4E00, 0x9FCF))
	print str

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/100413.html原文链接:

0 人点赞