1、ASCII字符对应的字符组 [\x00-\x7F]
例如:判断是否是ASCII字符
# -*- coding: UTF-8 -*- import re print (re.search("^[\x00-\x7F]$","c")!=None) print (re.search("^[\x00-\x7F]$","I")!=None) print (re.search("^[\x00-\x7F]$","0")!=None) print (re.search("^[\x00-\x7F]$","<")!=None) print (re.search("^[\x00-\x7F]$","@")!=None)
#正则表达式的提取 print (re.search("^[\x00-\x7F]$","@").group(0)) #匹配并提取所有的字符串,r 代表原生字符 for zipcode in re.findall(r"\d{6}","zipcode1:201203,zipcode2:100859"): print (zipcode)