File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ def is_chinese_char (c ):
2
+ """判断一个 unicode 字符是否是汉字"""
3
+ return '\u4e00 ' <= c <= '\u9fa5 '
4
+
5
+
6
+ def is_number_char (c ):
7
+ """判断一个 unicode 字符是否是数字"""
8
+ return '\u0030 ' <= c <= '\u0039 '
9
+
10
+
11
+ def is_alphabet_char (c ):
12
+ """判断一个 unicode 字符是否是英文字母"""
13
+ return '\u0041 ' <= c <= '\u005a ' or '\u0061 ' <= c <= '\u007a '
14
+
15
+
16
+ def main ():
17
+ c = '中'
18
+ print ('{} {}' .format (c , is_chinese_char (c )))
19
+ c = '國'
20
+ print ('{} {}' .format (c , is_chinese_char (c )))
21
+ c = '國'
22
+ print ('{} {}' .format (c , is_chinese_char (c )))
23
+ c = '冇'
24
+ print ('{} {}' .format (c , is_chinese_char (c )))
25
+ c = 'の'
26
+ print ('{} {}' .format (c , is_chinese_char (c )))
27
+ c = 'な'
28
+ print ('{} {}' .format (c , is_chinese_char (c )))
29
+ c = '漢'
30
+ print ('{} {}' .format (c , is_chinese_char (c )))
31
+ c = '말'
32
+ print ('{} {}' .format (c , is_chinese_char (c )))
33
+ c = '@'
34
+ print ('{} {}' .format (c , is_alphabet_char (c )))
35
+ c = '0'
36
+ print ('{} {}' .format (c , is_number_char (c )))
37
+
38
+
39
+ if __name__ == '__main__' :
40
+ main ()
You can’t perform that action at this time.
0 commit comments