Skip to content

Commit a70456a

Browse files
committed
update
1 parent 1f74e2d commit a70456a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

utils/011-unicode-range/app.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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()

0 commit comments

Comments
 (0)