12 lines
460 B
Python
12 lines
460 B
Python
|
import re
|
|||
|
|
|||
|
if __name__ == '__main__':
|
|||
|
# 默认情况下,re模块已经认识了某些unicode字符,比如\d现在已经可以匹配unicode的数字
|
|||
|
num = re.compile(r'\d+')
|
|||
|
# match会从第一个字符开始匹配,如果不匹配就返回None
|
|||
|
print(num.match('123'))
|
|||
|
|
|||
|
print(num.match('\u0661\u0662\u0663'))
|
|||
|
|
|||
|
# 我的评价是别这样干,在处理东西之前先将输入标准化为ascii编码是一个程序员的基本素养
|