优质回帖
1 回帖
-
J • 2023-08-10 11:41:39 1楼
牛
import re
def has_chinese(text):
pattern = re.compile(r’[\u4e00-\u9fa5]’)
result = re.search(pattern, text)
return result is not None测试示例
text1 = “Hello World!”
text2 = “你好,世界!”
print(has_chinese(text1)) # False
print(has_chinese(text2)) # True0 1 0
牛
import re
def has_chinese(text):
pattern = re.compile(r’[\u4e00-\u9fa5]’)
result = re.search(pattern, text)
return result is not None
测试示例
text1 = “Hello World!”
text2 = “你好,世界!”
print(has_chinese(text1)) # False
print(has_chinese(text2)) # True